use shorthand function in properties

stash 2
This commit is contained in:
Jare Guo
2017-02-17 12:49:38 +08:00
parent 787aa87759
commit fff91611cb
5 changed files with 180 additions and 179 deletions
+103 -103
View File
@@ -331,11 +331,11 @@ var Node = cc.Class({
* @type {String}
*/
group: {
get: function () {
get () {
return cc.game.groupList[this.groupIndex] || '';
},
set: function (value) {
set (value) {
this.groupIndex = cc.game.groupList.indexOf(value);
this.emit('group-changed');
}
@@ -353,10 +353,10 @@ var Node = cc.Class({
* cc.log("Node Position X: " + node.x);
*/
x: {
get: function () {
get () {
return this._position.x;
},
set: function (value) {
set (value) {
var localPosition = this._position;
if (value !== localPosition.x) {
if (!CC_EDITOR || isFinite(value)) {
@@ -399,10 +399,10 @@ var Node = cc.Class({
* cc.log("Node Position Y: " + node.y);
*/
y: {
get: function () {
get () {
return this._position.y;
},
set: function (value) {
set (value) {
var localPosition = this._position;
if (value !== localPosition.y) {
if (!CC_EDITOR || isFinite(value)) {
@@ -445,12 +445,12 @@ var Node = cc.Class({
* cc.log("Node Rotation: " + node.rotation);
*/
rotation: {
get: function () {
get () {
if (this._rotationX !== this._rotationY)
cc.logID(1602);
return this._rotationX;
},
set: function (value) {
set (value) {
if (this._rotationX !== value || this._rotationY !== value) {
this._rotationX = this._rotationY = value;
this._sgNode.rotation = value;
@@ -468,10 +468,10 @@ var Node = cc.Class({
* cc.log("Node Rotation X: " + node.rotationX);
*/
rotationX: {
get: function () {
get () {
return this._rotationX;
},
set: function (value) {
set (value) {
if (this._rotationX !== value) {
this._rotationX = value;
this._sgNode.rotationX = value;
@@ -489,10 +489,10 @@ var Node = cc.Class({
* cc.log("Node Rotation Y: " + node.rotationY);
*/
rotationY: {
get: function () {
get () {
return this._rotationY;
},
set: function (value) {
set (value) {
if (this._rotationY !== value) {
this._rotationY = value;
this._sgNode.rotationY = value;
@@ -510,10 +510,10 @@ var Node = cc.Class({
* cc.log("Node Scale X: " + node.scaleX);
*/
scaleX: {
get: function () {
get () {
return this._scaleX;
},
set: function (value) {
set (value) {
if (this._scaleX !== value) {
this._scaleX = value;
this._sgNode.scaleX = value;
@@ -531,10 +531,10 @@ var Node = cc.Class({
* cc.log("Node Scale Y: " + node.scaleY);
*/
scaleY: {
get: function () {
get () {
return this._scaleY;
},
set: function (value) {
set (value) {
if (this._scaleY !== value) {
this._scaleY = value;
this._sgNode.scaleY = value;
@@ -552,10 +552,10 @@ var Node = cc.Class({
* cc.log("Node SkewX: " + node.skewX);
*/
skewX: {
get: function () {
get () {
return this._skewX;
},
set: function (value) {
set (value) {
this._skewX = value;
this._sgNode.skewX = value;
}
@@ -571,10 +571,10 @@ var Node = cc.Class({
* cc.log("Node SkewY: " + node.skewY);
*/
skewY: {
get: function () {
get () {
return this._skewY;
},
set: function (value) {
set (value) {
this._skewY = value;
this._sgNode.skewY = value;
}
@@ -589,10 +589,10 @@ var Node = cc.Class({
* node.opacity = 255;
*/
opacity: {
get: function () {
get () {
return this._opacity;
},
set: function (value) {
set (value) {
if (this._opacity !== value) {
this._opacity = value;
this._sgNode.setOpacity(value);
@@ -616,10 +616,10 @@ var Node = cc.Class({
* cc.log("CascadeOpacity: " + node.cascadeOpacity);
*/
cascadeOpacity: {
get: function () {
get () {
return this._cascadeOpacityEnabled;
},
set: function (value) {
set (value) {
if (this._cascadeOpacityEnabled !== value) {
this._cascadeOpacityEnabled = value;
this._sgNode.cascadeOpacity = value;
@@ -642,10 +642,10 @@ var Node = cc.Class({
* node.color = new cc.Color(255, 255, 255);
*/
color: {
get: function () {
get () {
return this._color.clone()
},
set: function (value) {
set (value) {
if (!this._color.equals(value)) {
this._color.fromColor(value);
if (CC_DEV && value.a !== 255) {
@@ -667,10 +667,10 @@ var Node = cc.Class({
* node.anchorX = 0;
*/
anchorX: {
get: function () {
get () {
return this._anchorPoint.x;
},
set: function (value) {
set (value) {
var anchorPoint = this._anchorPoint;
if (anchorPoint.x !== value) {
anchorPoint.x = value;
@@ -692,10 +692,10 @@ var Node = cc.Class({
* node.anchorY = 0;
*/
anchorY: {
get: function () {
get () {
return this._anchorPoint.y;
},
set: function (value) {
set (value) {
var anchorPoint = this._anchorPoint;
if (anchorPoint.y !== value) {
anchorPoint.y = value;
@@ -717,7 +717,7 @@ var Node = cc.Class({
* node.width = 100;
*/
width: {
get: function () {
get () {
if (this._sizeProvider) {
var w = this._sizeProvider._getWidth();
this._contentSize.width = w;
@@ -727,7 +727,7 @@ var Node = cc.Class({
return this._contentSize.width;
}
},
set: function (value) {
set (value) {
if (value !== this._contentSize.width) {
var sizeProvider = this._sizeProvider;
if (sizeProvider) {
@@ -756,7 +756,7 @@ var Node = cc.Class({
* node.height = 100;
*/
height: {
get: function () {
get () {
if (this._sizeProvider) {
var h = this._sizeProvider._getHeight();
this._contentSize.height = h;
@@ -766,7 +766,7 @@ var Node = cc.Class({
return this._contentSize.height;
}
},
set: function (value) {
set (value) {
if (value !== this._contentSize.height) {
var sizeProvider = this._sizeProvider;
if (sizeProvider) {
@@ -793,10 +793,10 @@ var Node = cc.Class({
* @private
*/
_ignoreAnchor: {
get: function () {
get () {
return this.__ignoreAnchor;
},
set: function (value) {
set (value) {
if (this.__ignoreAnchor !== value) {
this.__ignoreAnchor = value;
this._sgNode.ignoreAnchor = value;
@@ -819,10 +819,10 @@ var Node = cc.Class({
* cc.log("Node zIndex: " + node.zIndex);
*/
zIndex: {
get: function () {
get () {
return this._localZOrder;
},
set: function (value) {
set (value) {
if (this._localZOrder !== value) {
this._localZOrder = value;
this._sgNode.zIndex = value;
@@ -837,7 +837,7 @@ var Node = cc.Class({
//properties moved from base node end
},
ctor: function (name) {
ctor (name) {
/**
* Current scene graph node for this node.
@@ -892,14 +892,14 @@ var Node = cc.Class({
statics: {
// is node but not scene
isNode: function (obj) {
isNode (obj) {
return obj instanceof Node && (obj.constructor === Node || !(obj instanceof cc.Scene));
}
},
// OVERRIDES
_onPreDestroy: function () {
_onPreDestroy () {
var destroyByParent = this._onPreDestroyBase();
cc.director.getActionManager().removeAllActionsFromTarget(this);
@@ -951,7 +951,7 @@ var Node = cc.Class({
/*
* The initializer for Node which will be called before all components onLoad
*/
_onBatchCreated: function () {
_onBatchCreated () {
var prefabInfo = this._prefab;
if (prefabInfo && prefabInfo.sync && !prefabInfo._synced) {
// checks to ensure no recursion, recursion will caused only on old data.
@@ -978,7 +978,7 @@ var Node = cc.Class({
}
},
_onActive_EventsActions: function (newActive) {
_onActive_EventsActions (newActive) {
// ActionManager, EventManager
if (newActive) {
// activate
@@ -998,7 +998,7 @@ var Node = cc.Class({
}
},
_onHierarchyChanged: function (oldParent) {
_onHierarchyChanged (oldParent) {
this._onHierarchyChangedBase(oldParent);
cc._widgetManager._nodesOrderDirty = true;
},
@@ -1035,7 +1035,7 @@ var Node = cc.Class({
* node.on(cc.Node.EventType.TOUCH_CANCEL, callback, this.node);
* node.on("anchor-changed", callback, this);
*/
on: function (type, callback, target, useCapture) {
on (type, callback, target, useCapture) {
var newAdded = false;
if (_touchEvents.indexOf(type) !== -1) {
if (!this._touchListener) {
@@ -1103,7 +1103,7 @@ var Node = cc.Class({
* node.off(cc.Node.EventType.TOUCH_START, callback, this.node);
* node.off("anchor-changed", callback, this);
*/
off: function (type, callback, target, useCapture) {
off (type, callback, target, useCapture) {
this._EventTargetOff(type, callback, target, useCapture);
if (_touchEvents.indexOf(type) !== -1) {
@@ -1122,14 +1122,14 @@ var Node = cc.Class({
* @example
* node.targetOff(target);
*/
targetOff: function (target) {
targetOff (target) {
this._EventTargetTargetOff(target);
this._checkTouchListeners();
this._checkMouseListeners();
},
_checkTouchListeners: function () {
_checkTouchListeners () {
if (!(this._objFlags & Destroying) && this._touchListener) {
var i = 0;
if (this._bubblingListeners) {
@@ -1151,7 +1151,7 @@ var Node = cc.Class({
this._touchListener = null;
}
},
_checkMouseListeners: function () {
_checkMouseListeners () {
if (!(this._objFlags & Destroying) && this._mouseListener) {
var i = 0;
if (this._bubblingListeners) {
@@ -1178,7 +1178,7 @@ var Node = cc.Class({
}
},
_hitTest: function (point, listener) {
_hitTest (point, listener) {
var w = this.width,
h = this.height;
var rect = cc.rect(0, 0, w, h);
@@ -1215,7 +1215,7 @@ var Node = cc.Class({
},
// Store all capturing parents that are listening to the same event in the array
_getCapturingTargets: function (type, array) {
_getCapturingTargets (type, array) {
var parent = this.parent;
while (parent) {
if (parent.hasEventListener(type, true)) {
@@ -1226,7 +1226,7 @@ var Node = cc.Class({
},
// Store all bubbling parents that are listening to the same event in the array
_getBubblingTargets: function (type, array) {
_getBubblingTargets (type, array) {
var parent = this.parent;
while (parent) {
if (parent.hasEventListener(type)) {
@@ -1237,7 +1237,7 @@ var Node = cc.Class({
},
// for event manager
isRunning: function () {
isRunning () {
return this._activeInHierarchy;
},
@@ -1262,7 +1262,7 @@ var Node = cc.Class({
* node.runAction(action).repeatForever(); // fail
* node.runAction(action.repeatForever()); // right
*/
runAction: function (action) {
runAction (action) {
if (!this.active)
return;
cc.assertID(action, 1618);
@@ -1284,7 +1284,7 @@ var Node = cc.Class({
* @example
* node.stopAllActions();
*/
stopAllActions: function () {
stopAllActions () {
cc.director.getActionManager().removeAllActionsFromTarget(this);
},
@@ -1297,7 +1297,7 @@ var Node = cc.Class({
* var action = cc.scaleTo(0.2, 1, 0.6);
* node.stopAction(action);
*/
stopAction: function (action) {
stopAction (action) {
cc.director.getActionManager().removeAction(action);
},
@@ -1309,7 +1309,7 @@ var Node = cc.Class({
* @example
* node.stopAction(1);
*/
stopActionByTag: function (tag) {
stopActionByTag (tag) {
if (tag === cc.Action.TAG_INVALID) {
cc.logID(1612);
return;
@@ -1327,7 +1327,7 @@ var Node = cc.Class({
* @example
* var action = node.getActionByTag(1);
*/
getActionByTag: function (tag) {
getActionByTag (tag) {
if (tag === cc.Action.TAG_INVALID) {
cc.logID(1613);
return null;
@@ -1353,18 +1353,18 @@ var Node = cc.Class({
* var count = node.getNumberOfRunningActions();
* cc.log("Running Action Count: " + count);
*/
getNumberOfRunningActions: function () {
getNumberOfRunningActions () {
return cc.director.getActionManager().getNumberOfRunningActionsInTarget(this);
},
_retainAction: function (action) {
_retainAction (action) {
if (CC_JSB && action instanceof cc.Action && this._retainedActions.indexOf(action) === -1) {
this._retainedActions.push(action);
action.retain();
}
},
_releaseAllActions: function () {
_releaseAllActions () {
if (CC_JSB) {
for (var i = 0; i < this._retainedActions.length; ++i) {
this._retainedActions[i].release();
@@ -1376,12 +1376,12 @@ var Node = cc.Class({
//functions moved from base node begin
//override
setTag: function (value) {
setTag (value) {
this._tag = value;
this._sgNode.tag = value;
},
setParent: function (value) {
setParent (value) {
if (this._parent === value) {
return;
}
@@ -1420,7 +1420,7 @@ var Node = cc.Class({
}
},
_onSiblingIndexChanged: function (index) {
_onSiblingIndexChanged (index) {
// update rendering scene graph, sort them by arrivalOrder
var parent = this._parent;
var siblings = parent._children;
@@ -1468,7 +1468,7 @@ var Node = cc.Class({
* @example
* cc.log("Node Position: " + node.getPosition());
*/
getPosition: function () {
getPosition () {
return cc.p(this._position);
},
@@ -1488,7 +1488,7 @@ var Node = cc.Class({
* @param {Number} [yValue] - Y coordinate for position
* @example {@link utils/api/engine/docs/cocos2d/core/utils/base-node/setPosition.js}
*/
setPosition: function (newPosOrxValue, yValue) {
setPosition (newPosOrxValue, yValue) {
var xValue;
if (typeof yValue === 'undefined') {
xValue = newPosOrxValue.x;
@@ -1549,7 +1549,7 @@ var Node = cc.Class({
* @example
* cc.log("Node Scale: " + node.getScale());
*/
getScale: function () {
getScale () {
if (this._scaleX !== this._scaleY)
cc.logID(1603);
return this._scaleX;
@@ -1565,7 +1565,7 @@ var Node = cc.Class({
* node.setScale(cc.v2(1, 1));
* node.setScale(1, 1);
*/
setScale: function (scaleX, scaleY) {
setScale (scaleX, scaleY) {
if (typeof scaleX === 'object') {
scaleY = scaleX.y;
scaleX = scaleX.x
@@ -1592,7 +1592,7 @@ var Node = cc.Class({
* @example
* cc.log("Content Size: " + node.getContentSize());
*/
getContentSize: function (ignoreSizeProvider) {
getContentSize (ignoreSizeProvider) {
if (this._sizeProvider && !ignoreSizeProvider) {
var size = this._sizeProvider.getContentSize();
this._contentSize = size;
@@ -1616,7 +1616,7 @@ var Node = cc.Class({
* node.setContentSize(cc.size(100, 100));
* node.setContentSize(100, 100);
*/
setContentSize: function (size, height) {
setContentSize (size, height) {
var locContentSize = this._contentSize;
var clone;
if (height === undefined) {
@@ -1657,7 +1657,7 @@ var Node = cc.Class({
* @example
* node.setOpacityModifyRGB(true);
*/
setOpacityModifyRGB: function (opacityValue) {
setOpacityModifyRGB (opacityValue) {
if (this._opacityModifyRGB !== opacityValue) {
this._opacityModifyRGB = opacityValue;
this._sgNode.setOpacityModifyRGB(opacityValue);
@@ -1676,7 +1676,7 @@ var Node = cc.Class({
* @example
* var hasChange = node.isOpacityModifyRGB();
*/
isOpacityModifyRGB: function () {
isOpacityModifyRGB () {
return this._opacityModifyRGB;
},
@@ -1712,7 +1712,7 @@ var Node = cc.Class({
* @example
* node.setGlobalZOrder(0);
*/
setGlobalZOrder: function (globalZOrder) {
setGlobalZOrder (globalZOrder) {
this._globalZOrder = globalZOrder;
this._sgNode.setGlobalZOrder(globalZOrder);
},
@@ -1725,7 +1725,7 @@ var Node = cc.Class({
* @example
* cc.log("Global Z Order: " + node.getGlobalZOrder());
*/
getGlobalZOrder: function () {
getGlobalZOrder () {
this._globalZOrder = this._sgNode.getGlobalZOrder();
return this._globalZOrder;
},
@@ -1750,7 +1750,7 @@ var Node = cc.Class({
* @example
* cc.log("Node AnchorPoint: " + node.getAnchorPoint());
*/
getAnchorPoint: function () {
getAnchorPoint () {
return cc.p(this._anchorPoint);
},
@@ -1776,7 +1776,7 @@ var Node = cc.Class({
* node.setAnchorPoint(cc.v2(1, 1));
* node.setAnchorPoint(1, 1);
*/
setAnchorPoint: function (point, y) {
setAnchorPoint (point, y) {
var locAnchorPoint = this._anchorPoint;
if (y === undefined) {
if ((point.x === locAnchorPoint.x) && (point.y === locAnchorPoint.y))
@@ -1809,7 +1809,7 @@ var Node = cc.Class({
* @example
* cc.log("AnchorPointInPoints: " + node.getAnchorPointInPoints());
*/
getAnchorPointInPoints: function () {
getAnchorPointInPoints () {
return this._sgNode.getAnchorPointInPoints();
},
@@ -1827,7 +1827,7 @@ var Node = cc.Class({
* @example
* var displayOpacity = node.getDisplayedOpacity();
*/
getDisplayedOpacity: function () {
getDisplayedOpacity () {
return this._sgNode.getDisplayedOpacity();
},
@@ -1839,7 +1839,7 @@ var Node = cc.Class({
* @example
* node._updateDisplayedOpacity(255);
*/
_updateDisplayedOpacity: function (parentOpacity) {
_updateDisplayedOpacity (parentOpacity) {
this._sgNode.updateDisplayedOpacity(parentOpacity);
},
@@ -1855,7 +1855,7 @@ var Node = cc.Class({
* @example
* var displayColor = node.getDisplayedColor();
*/
getDisplayedColor: function () {
getDisplayedColor () {
return this._sgNode.getDisplayedColor();
},
@@ -1873,7 +1873,7 @@ var Node = cc.Class({
* @example
* var affineTransform = node.getNodeToParentTransformAR();
*/
getNodeToParentTransformAR: function () {
getNodeToParentTransformAR () {
var contentSize = this.getContentSize();
var mat = this._sgNode.getNodeToParentTransform();
if (!this._isSgTransformArToMe(contentSize)) {
@@ -1896,7 +1896,7 @@ var Node = cc.Class({
* @example
* var boundingBox = node.getBoundingBox();
*/
getBoundingBox: function () {
getBoundingBox () {
var size = this.getContentSize();
var rect = cc.rect(0, 0, size.width, size.height);
return cc._rectApplyAffineTransformIn(rect, this.getNodeToParentTransform());
@@ -1914,7 +1914,7 @@ var Node = cc.Class({
* @example
* var newRect = node.getBoundingBoxToWorld();
*/
getBoundingBoxToWorld: function () {
getBoundingBoxToWorld () {
var trans;
if (this.parent) {
trans = this.parent.getNodeToWorldTransformAR();
@@ -1922,7 +1922,7 @@ var Node = cc.Class({
return this._getBoundingBoxTo(trans);
},
_getBoundingBoxTo: function (parentTransformAR) {
_getBoundingBoxTo (parentTransformAR) {
var size = this.getContentSize();
var width = size.width;
var height = size.height;
@@ -1957,7 +1957,7 @@ var Node = cc.Class({
* @example
* var affineTransform = node.getNodeToParentTransform();
*/
getNodeToParentTransform: function () {
getNodeToParentTransform () {
var contentSize = this.getContentSize();
var mat = this._sgNode.getNodeToParentTransform();
if (this._isSgTransformArToMe(contentSize)) {
@@ -1978,7 +1978,7 @@ var Node = cc.Class({
* @example
* var affineTransform = node.getNodeToWorldTransform();
*/
getNodeToWorldTransform: function () {
getNodeToWorldTransform () {
var contentSize = this.getContentSize();
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
@@ -2011,7 +2011,7 @@ var Node = cc.Class({
* @example
* var mat = node.getNodeToWorldTransformAR();
*/
getNodeToWorldTransformAR: function () {
getNodeToWorldTransformAR () {
var contentSize = this.getContentSize();
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
@@ -2042,7 +2042,7 @@ var Node = cc.Class({
* @example
* var affineTransform = node.getParentToNodeTransform();
*/
getParentToNodeTransform: function () {
getParentToNodeTransform () {
return this._sgNode.getParentToNodeTransform();
},
@@ -2054,7 +2054,7 @@ var Node = cc.Class({
* @example
* var affineTransform = node.getWorldToNodeTransform();
*/
getWorldToNodeTransform: function () {
getWorldToNodeTransform () {
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
// ensure transform computed
cc.director._visitScene();
@@ -2062,7 +2062,7 @@ var Node = cc.Class({
return this._sgNode.getWorldToNodeTransform();
},
_isSgTransformArToMe: function (myContentSize) {
_isSgTransformArToMe (myContentSize) {
var renderSize = this._sgNode.getContentSize();
if (renderSize.width === 0 && renderSize.height === 0 &&
(myContentSize.width !== 0 || myContentSize.height !== 0)) {
@@ -2085,7 +2085,7 @@ var Node = cc.Class({
* @example
* var newVec2 = node.convertToNodeSpace(cc.v2(100, 100));
*/
convertToNodeSpace: function (worldPoint) {
convertToNodeSpace (worldPoint) {
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
// ensure transform computed
cc.director._visitScene();
@@ -2103,7 +2103,7 @@ var Node = cc.Class({
* @example
* var newVec2 = node.convertToWorldSpace(cc.v2(100, 100));
*/
convertToWorldSpace: function (nodePoint) {
convertToWorldSpace (nodePoint) {
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
// ensure transform computed
cc.director._visitScene();
@@ -2126,7 +2126,7 @@ var Node = cc.Class({
* @example
* var newVec2 = node.convertToNodeSpaceAR(cc.v2(100, 100));
*/
convertToNodeSpaceAR: function (worldPoint) {
convertToNodeSpaceAR (worldPoint) {
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
// ensure transform computed
cc.director._visitScene();
@@ -2153,7 +2153,7 @@ var Node = cc.Class({
* @example
* var newVec2 = node.convertToWorldSpaceAR(cc.v2(100, 100));
*/
convertToWorldSpaceAR: function (nodePoint) {
convertToWorldSpaceAR (nodePoint) {
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
// ensure transform computed
cc.director._visitScene();
@@ -2176,7 +2176,7 @@ var Node = cc.Class({
* @example
* var newVec2 = node.convertTouchToNodeSpace(touch);
*/
convertTouchToNodeSpace: function (touch) {
convertTouchToNodeSpace (touch) {
return this.convertToNodeSpace(touch.getLocation());
},
@@ -2189,11 +2189,11 @@ var Node = cc.Class({
* @example
* var newVec2 = node.convertTouchToNodeSpaceAR(touch);
*/
convertTouchToNodeSpaceAR: function (touch) {
convertTouchToNodeSpaceAR (touch) {
return this.convertToNodeSpaceAR(touch.getLocation());
},
setNodeDirty: function () {
setNodeDirty () {
this._sgNode.setNodeDirty();
},
@@ -2209,7 +2209,7 @@ var Node = cc.Class({
* @example
* node.addChild(newNode, 1, 1001);
*/
addChild: function (child, localZOrder, tag) {
addChild (child, localZOrder, tag) {
localZOrder = localZOrder === undefined ? child._localZOrder : localZOrder;
var name, setTag = false;
if (typeof tag === 'undefined') {
@@ -2246,7 +2246,7 @@ var Node = cc.Class({
* @example
* node.cleanup();
*/
cleanup: function () {
cleanup () {
// actions
cc.director.getActionManager().removeAllActionsFromTarget(this);
// event
@@ -2268,7 +2268,7 @@ var Node = cc.Class({
*
* @method sortAllChildren
*/
sortAllChildren: function () {
sortAllChildren () {
if (this._reorderChildDirty) {
this._reorderChildDirty = false;
var _children = this._children;
@@ -2299,14 +2299,14 @@ var Node = cc.Class({
}
},
_delaySort: function () {
_delaySort () {
if (!this._reorderChildDirty) {
this._reorderChildDirty = true;
cc.director.__fastOn(cc.Director.EVENT_AFTER_UPDATE, this.sortAllChildren, this);
}
},
_updateDummySgNode: function () {
_updateDummySgNode () {
var self = this;
var sgNode = self._sgNode;
@@ -2334,7 +2334,7 @@ var Node = cc.Class({
sgNode.setTag(self._tag);
},
_updateSgNode: function () {
_updateSgNode () {
this._updateDummySgNode();
var sgNode = this._sgNode;
sgNode.setAnchorPoint(this._anchorPoint);
+23 -23
View File
@@ -82,7 +82,7 @@ var Component = cc.Class({
},
name: {
get: function () {
get () {
if (this._name) {
return this._name;
}
@@ -93,7 +93,7 @@ var Component = cc.Class({
}
return this.node.name + '<' + className + '>';
},
set: function (value) {
set (value) {
this._name = value;
},
visible: false
@@ -114,7 +114,7 @@ var Component = cc.Class({
* cc.log(comp.uuid);
*/
uuid: {
get: function () {
get () {
var id = this._id;
if ( !id ) {
id = this._id = idGenerater.getNewId();
@@ -128,8 +128,8 @@ var Component = cc.Class({
},
__scriptAsset: CC_EDITOR && {
get: function () {},
//set: function (value) {
get () {},
//set (value) {
// if (this.__scriptUuid !== value) {
// if (value && Editor.Utils.UuidUtils.isUuid(value._uuid)) {
// var classId = Editor.Utils.UuidUtils.compressUuid(value._uuid);
@@ -170,10 +170,10 @@ var Component = cc.Class({
* cc.log(comp.enabled);
*/
enabled: {
get: function () {
get () {
return this._enabled;
},
set: function (value) {
set (value) {
if (this._enabled !== value) {
this._enabled = value;
if (this.node._activeInHierarchy) {
@@ -199,7 +199,7 @@ var Component = cc.Class({
* cc.log(comp.enabledInHierarchy);
*/
enabledInHierarchy: {
get: function () {
get () {
return (this._objFlags & IsOnEnableCalled) > 0;
},
visible: false
@@ -215,7 +215,7 @@ var Component = cc.Class({
* cc.log(_isOnLoadCalled > 0);
*/
_isOnLoadCalled: {
get: function () {
get () {
return this._objFlags & IsOnLoadCalled;
}
},
@@ -314,7 +314,7 @@ var Component = cc.Class({
* var sprite = node.addComponent(cc.Sprite);
* var test = node.addComponent("Test");
*/
addComponent: function (typeOrTypename) {
addComponent (typeOrTypename) {
return this.node.addComponent(typeOrTypename);
},
@@ -335,7 +335,7 @@ var Component = cc.Class({
* // get custom test calss.
* var test = node.getComponent("Test");
*/
getComponent: function (typeOrClassName) {
getComponent (typeOrClassName) {
return this.node.getComponent(typeOrClassName);
},
@@ -350,7 +350,7 @@ var Component = cc.Class({
* var sprites = node.getComponents(cc.Sprite);
* var tests = node.getComponents("Test");
*/
getComponents: function (typeOrClassName) {
getComponents (typeOrClassName) {
return this.node.getComponents(typeOrClassName);
},
@@ -365,7 +365,7 @@ var Component = cc.Class({
* var sprite = node.getComponentInChildren(cc.Sprite);
* var Test = node.getComponentInChildren("Test");
*/
getComponentInChildren: function (typeOrClassName) {
getComponentInChildren (typeOrClassName) {
return this.node.getComponentInChildren(typeOrClassName);
},
@@ -380,7 +380,7 @@ var Component = cc.Class({
* var sprites = node.getComponentsInChildren(cc.Sprite);
* var tests = node.getComponentsInChildren("Test");
*/
getComponentsInChildren: function (typeOrClassName) {
getComponentsInChildren (typeOrClassName) {
return this.node.getComponentsInChildren(typeOrClassName);
},
@@ -444,7 +444,7 @@ var Component = cc.Class({
// OVERRIDE
destroy: function () {
destroy () {
if (CC_EDITOR) {
var depend = this.node._getDependComponent(this);
if (depend) {
@@ -459,7 +459,7 @@ var Component = cc.Class({
}
},
_onPreDestroy: function () {
_onPreDestroy () {
// Schedules
this.unscheduleAllCallbacks();
@@ -487,7 +487,7 @@ var Component = cc.Class({
}
},
_instantiate: function (cloned) {
_instantiate (cloned) {
if (!cloned) {
cloned = cc.instantiate._clone(this, this);
}
@@ -497,7 +497,7 @@ var Component = cc.Class({
// Scheduler
isRunning: function () {
isRunning () {
return this.enabledInHierarchy;
},
@@ -519,7 +519,7 @@ var Component = cc.Class({
* }
* this.schedule(timeCallback, 1);
*/
schedule: function (callback, interval, repeat, delay) {
schedule (callback, interval, repeat, delay) {
cc.assertID(callback, 1619);
cc.assertID(interval >= 0, 1620);
@@ -543,7 +543,7 @@ var Component = cc.Class({
* }
* this.scheduleOnce(timeCallback, 2);
*/
scheduleOnce: function (callback, delay) {
scheduleOnce (callback, delay) {
this.schedule(callback, 0, 0, delay);
},
@@ -556,7 +556,7 @@ var Component = cc.Class({
* @example
* this.unschedule(_callback);
*/
unschedule: function (callback_fn) {
unschedule (callback_fn) {
if (!callback_fn)
return;
@@ -572,7 +572,7 @@ var Component = cc.Class({
* @example
* this.unscheduleAllCallbacks();
*/
unscheduleAllCallbacks: function () {
unscheduleAllCallbacks () {
cc.director.getScheduler().unscheduleAllForTarget(this);
},
});
@@ -608,7 +608,7 @@ if (CC_EDITOR || CC_TEST) {
// use defineProperty to prevent inherited by sub classes
Object.defineProperty(Component, '_registerEditorProps', {
value: function (cls, props) {
value (cls, props) {
var reqComp = props.requireComponent;
if (reqComp) {
cls._requireComponent = reqComp;
+1 -1
View File
@@ -599,7 +599,7 @@ function _createCtor (baseClass, mixins, className, options) {
}
// check ctor
if (ctor.length > 0 && !className.startsWith('cc.')) {
if (ctor.length > 0 && (!className || !className.startsWith('cc.'))) {
// fireball-x/dev#138: To make a unified CCClass serialization process,
// we don't allow parameters for constructor when creating instances of CCClass.
// For advance user, construct arguments can still get from 'arguments'.
+44 -44
View File
@@ -150,10 +150,10 @@ var BaseNode = cc.Class({
* @private
*/
_persistNode: {
get: function () {
get () {
return (this._objFlags & DontDestroy) > 0;
},
set: function (value) {
set (value) {
if (value) {
this._objFlags |= DontDestroy;
}
@@ -175,10 +175,10 @@ var BaseNode = cc.Class({
* cc.log("Node Name: " + node.name);
*/
name: {
get: function () {
get () {
return this._name;
},
set: function (value) {
set (value) {
if (CC_DEV && value.indexOf('/') !== -1) {
cc.errorID(1632);
return;
@@ -212,7 +212,7 @@ var BaseNode = cc.Class({
* cc.log("Node Uuid: " + node.uuid);
*/
uuid: {
get: function () {
get () {
var id = this._id;
if (!id) {
id = this._id = CC_EDITOR ? Editor.Utils.UuidUtils.uuid() : idGenerater.getNewId();
@@ -234,7 +234,7 @@ var BaseNode = cc.Class({
* }
*/
children: {
get: function () {
get () {
return this._children;
}
},
@@ -250,7 +250,7 @@ var BaseNode = cc.Class({
* cc.log("Node Children Count: " + count);
*/
childrenCount: {
get: function () {
get () {
return this._children.length;
}
},
@@ -271,10 +271,10 @@ var BaseNode = cc.Class({
* node.active = false;
*/
active: {
get: function () {
get () {
return this._active;
},
set: function (value) {
set (value) {
value = !!value;
if (this._active !== value) {
this._active = value;
@@ -296,7 +296,7 @@ var BaseNode = cc.Class({
* cc.log("activeInHierarchy: " + node.activeInHierarchy);
*/
activeInHierarchy: {
get: function () {
get () {
return this._activeInHierarchy;
}
},
@@ -312,7 +312,7 @@ var BaseNode = cc.Class({
},
ctor: function (name) {
ctor (name) {
this._name = typeof name !== 'undefined' ? name : 'New Node';
@@ -330,19 +330,19 @@ var BaseNode = cc.Class({
this.__eventTargets = [];
},
getTag: function () {
getTag () {
return this._tag;
},
setTag: function (tag) {
setTag (tag) {
this._tag = tag;
},
getParent: function () {
getParent () {
return this._parent;
},
setParent: function (value) {
setParent (value) {
if (this._parent === value) {
return;
}
@@ -387,7 +387,7 @@ var BaseNode = cc.Class({
* @returns {Boolean} Whether the initialization was successful.
* @deprecated, no need anymore
*/
init: function () {
init () {
return true;
},
@@ -404,7 +404,7 @@ var BaseNode = cc.Class({
* var attrs = { key: 0, num: 100 };
* node.attr(attrs);
*/
attr: function (attrs) {
attr (attrs) {
for (var key in attrs) {
this[key] = attrs[key];
}
@@ -421,7 +421,7 @@ var BaseNode = cc.Class({
* @example
* var child = node.getChildByTag(1001);
*/
getChildByTag: function (aTag) {
getChildByTag (aTag) {
var children = this._children;
if (children !== null) {
for (var i = 0; i < children.length; i++) {
@@ -442,7 +442,7 @@ var BaseNode = cc.Class({
* @example
* var child = node.getChildByUuid(uuid);
*/
getChildByUuid: function (uuid) {
getChildByUuid (uuid) {
if (!uuid) {
cc.log("Invalid uuid");
return null;
@@ -465,7 +465,7 @@ var BaseNode = cc.Class({
* @example
* var child = node.getChildByName("Test Node");
*/
getChildByName: function (name) {
getChildByName (name) {
if (!name) {
cc.log("Invalid name");
return null;
@@ -480,7 +480,7 @@ var BaseNode = cc.Class({
},
// composition: ADD
addChild: function (child) {
addChild (child) {
if (CC_DEV && !(child instanceof cc._BaseNode)) {
return cc.errorID(1634, cc.js.getClassName(child));
@@ -503,7 +503,7 @@ var BaseNode = cc.Class({
* @example
* var index = node.getSiblingIndex();
*/
getSiblingIndex: function () {
getSiblingIndex () {
if (this._parent) {
return this._parent._children.indexOf(this);
}
@@ -520,7 +520,7 @@ var BaseNode = cc.Class({
* @example
* node.setSiblingIndex(1);
*/
setSiblingIndex: function (index) {
setSiblingIndex (index) {
if (!this._parent) {
return;
}
@@ -539,7 +539,7 @@ var BaseNode = cc.Class({
}
},
cleanup: function () {
cleanup () {
},
@@ -559,7 +559,7 @@ var BaseNode = cc.Class({
* node.removeFromParent();
* node.removeFromParent(false);
*/
removeFromParent: function (cleanup) {
removeFromParent (cleanup) {
if (this._parent) {
if (cleanup === undefined)
cleanup = true;
@@ -584,7 +584,7 @@ var BaseNode = cc.Class({
* node.removeChild(newNode);
* node.removeChild(newNode, false);
*/
removeChild: function (child, cleanup) {
removeChild (child, cleanup) {
if (this._children.indexOf(child) > -1) {
// If you don't do cleanup, the child's actions will not get removed and the
if (cleanup || cleanup === undefined) {
@@ -610,7 +610,7 @@ var BaseNode = cc.Class({
* node.removeChildByTag(1001);
* node.removeChildByTag(1001, false);
*/
removeChildByTag: function (tag, cleanup) {
removeChildByTag (tag, cleanup) {
if (tag === cc.macro.NODE_TAG_INVALID)
cc.logID(1609);
@@ -634,7 +634,7 @@ var BaseNode = cc.Class({
* node.removeAllChildren();
* node.removeAllChildren(false);
*/
removeAllChildren: function (cleanup) {
removeAllChildren (cleanup) {
// not using detachChild improves speed here
var children = this._children;
if (cleanup === undefined)
@@ -666,7 +666,7 @@ var BaseNode = cc.Class({
* @example
* node.isChildOf(newNode);
*/
isChildOf: function (parent) {
isChildOf (parent) {
var child = this;
do {
if (child === parent) {
@@ -696,7 +696,7 @@ var BaseNode = cc.Class({
* // get custom test calss.
* var test = node.getComponent("Test");
*/
getComponent: function (typeOrClassName) {
getComponent (typeOrClassName) {
var constructor = getConstructor(typeOrClassName);
if (constructor) {
return findComponent(this, constructor);
@@ -714,7 +714,7 @@ var BaseNode = cc.Class({
* var sprites = node.getComponents(cc.Sprite);
* var tests = node.getComponents("Test");
*/
getComponents: function (typeOrClassName) {
getComponents (typeOrClassName) {
var constructor = getConstructor(typeOrClassName), components = [];
if (constructor) {
findComponents(this, constructor, components);
@@ -732,7 +732,7 @@ var BaseNode = cc.Class({
* var sprite = node.getComponentInChildren(cc.Sprite);
* var Test = node.getComponentInChildren("Test");
*/
getComponentInChildren: function (typeOrClassName) {
getComponentInChildren (typeOrClassName) {
var constructor = getConstructor(typeOrClassName);
if (constructor) {
return findChildComponent(this._children, constructor);
@@ -750,7 +750,7 @@ var BaseNode = cc.Class({
* var sprites = node.getComponentsInChildren(cc.Sprite);
* var tests = node.getComponentsInChildren("Test");
*/
getComponentsInChildren: function (typeOrClassName) {
getComponentsInChildren (typeOrClassName) {
var constructor = getConstructor(typeOrClassName), components = [];
if (constructor) {
findComponents(this, constructor, components);
@@ -783,7 +783,7 @@ var BaseNode = cc.Class({
* var sprite = node.addComponent(cc.Sprite);
* var test = node.addComponent("Test");
*/
addComponent: function (typeOrClassName) {
addComponent (typeOrClassName) {
if (CC_EDITOR && (this._objFlags & Destroying)) {
cc.error('isDestroying');
@@ -928,7 +928,7 @@ var BaseNode = cc.Class({
* var Test = require("Test");
* node.removeComponent(Test);
*/
removeComponent: function (component) {
removeComponent (component) {
if (!component) {
cc.errorID(3813);
return;
@@ -961,7 +961,7 @@ var BaseNode = cc.Class({
},
// do remove component, only used internally
_removeComponent: function (component) {
_removeComponent (component) {
if (!component) {
cc.errorID(3814);
return;
@@ -978,14 +978,14 @@ var BaseNode = cc.Class({
}
},
_onActivatedInHierarchy: function (newActive) {
_onActivatedInHierarchy (newActive) {
if (newActive) {
cc.director._compScheduler.preloadNode(this);
}
this._activeRecursively(newActive);
},
_activeRecursively: function (newActive) {
_activeRecursively (newActive) {
var cancelActivation = false;
if (this._objFlags & Activating) {
if (newActive) {
@@ -1056,7 +1056,7 @@ var BaseNode = cc.Class({
}
},
_deactivateChildComponents: function () {
_deactivateChildComponents () {
// 和 _activeRecursively 类似但不修改 this._activeInHierarchy
var originCount = this._components.length;
for (var c = 0; c < originCount; ++c) {
@@ -1074,7 +1074,7 @@ var BaseNode = cc.Class({
}
},
destroy: function () {
destroy () {
if (cc.Object.prototype.destroy.call(this)) {
// disable hierarchy
if (this._activeInHierarchy) {
@@ -1094,14 +1094,14 @@ var BaseNode = cc.Class({
* @example
* node.destroyAllChildren();
*/
destroyAllChildren: function () {
destroyAllChildren () {
var children = this._children;
for (var i = 0; i < children.length; ++i) {
children[i].destroy();
}
},
_onHierarchyChanged: function (oldParent) {
_onHierarchyChanged (oldParent) {
var newParent = this._parent;
if (this._persistNode && !(newParent instanceof cc.Scene)) {
cc.game.removePersistRootNode(this);
@@ -1151,7 +1151,7 @@ var BaseNode = cc.Class({
},
_onBatchCreated: function () {
_onBatchCreated () {
var prefabInfo = this._prefab;
if (prefabInfo && prefabInfo.sync && !prefabInfo._synced) {
// checks to ensure no recursion, recursion will caused only on old data.
@@ -1166,7 +1166,7 @@ var BaseNode = cc.Class({
}
},
_instantiate: function (cloned) {
_instantiate (cloned) {
if (!cloned) {
cloned = cc.instantiate._clone(this, this);
}
+9 -8
View File
@@ -576,22 +576,23 @@ cc.GLProgram = cc._Class.extend(/** @lends cc.GLProgram# */{
this._glContext.uniformMatrix4fv(locObj, false, matrixArray);
},
setUniformLocationF32: function () {
if (arguments.length < 2)
return;
setUniformLocationF32: function (p1, p2, p3, p4, p5) {
'use strict';
switch (arguments.length) {
case 0:
case 1:
return;
case 2:
this.setUniformLocationWith1f(arguments[0], arguments[1]);
this.setUniformLocationWith1f(p1, p2);
break;
case 3:
this.setUniformLocationWith2f(arguments[0], arguments[1], arguments[2]);
this.setUniformLocationWith2f(p1, p2, p3);
break;
case 4:
this.setUniformLocationWith3f(arguments[0], arguments[1], arguments[2], arguments[3]);
this.setUniformLocationWith3f(p1, p2, p3, p4);
break;
case 5:
this.setUniformLocationWith4f(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]);
this.setUniformLocationWith4f(p1, p2, p3, p4, p5);
break;
}
},