Skip to content

Commit c86601f

Browse files
committed
Merge pull request #2468 from pandamicro/next
#20: Revert panda version serialization
2 parents 5f2ffa2 + 1eb3403 commit c86601f

File tree

5 files changed

+179
-338
lines changed

5 files changed

+179
-338
lines changed

cocos2d/core/base-nodes/CCNode.js

Lines changed: 30 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ cc.s_globalOrderOfArrival = 1;
129129
* @property {Number} glServerState - The state of OpenGL server side
130130
*/
131131
cc.Node = cc.Class.extend(/** @lends cc.Node# */{
132-
__type: "cc.Node",
133-
134132
_localZOrder: 0, ///< Local order (relative to its siblings) used to sort the node
135133
_globalZOrder: 0, ///< Global order used to sort the node
136134
_vertexZ: 0.0,
@@ -249,7 +247,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
249247
return;
250248

251249
var i, len = array.length, node;
252-
var nodeCallbackType = cc.Node._StateCallbackType;
250+
var nodeCallbackType = cc.Node._stateCallbackType;
253251
switch (callbackType) {
254252
case nodeCallbackType.onEnter:
255253
for (i = 0; i < len; i++) {
@@ -310,7 +308,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
310308
* Sets node's dirty flag to true so that it can be updated in visit function of the next frame
311309
* @function
312310
*/
313-
//setNodeDirty: null,
311+
setNodeDirty: null,
314312

315313
/**
316314
* <p>Properties configuration function </br>
@@ -787,21 +785,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
787785
return this._children;
788786
},
789787

790-
/**
791-
* Add an array of node as children of this node <br/>
792-
* Composing a "tree" structure is a very important feature of CCNode
793-
* @function
794-
* @param {Array} children An array of children
795-
*/
796-
setChildren: function (children) {
797-
var i, l, child;
798-
for (i = 0, l = children.length; i < l; i++) {
799-
child = children[i];
800-
if (child instanceof cc.Node)
801-
this.addChild(child);
802-
}
803-
},
804-
805788
/**
806789
* Returns if the node is visible
807790
* @function
@@ -1080,7 +1063,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
10801063
* @param {String} name
10811064
*/
10821065
setName: function(name){
1083-
this._name = name;
1066+
this._name = name;
10841067
},
10851068

10861069
/**
@@ -1258,7 +1241,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
12581241
cc.eventManager.removeListeners(this);
12591242

12601243
// timers
1261-
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.cleanup);
1244+
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.cleanup);
12621245
},
12631246

12641247
// composition: GET
@@ -1294,8 +1277,8 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
12941277

12951278
var locChildren = this._children;
12961279
for(var i = 0, len = locChildren.length; i < len; i++){
1297-
if(locChildren[i]._name == name)
1298-
return locChildren[i];
1280+
if(locChildren[i]._name == name)
1281+
return locChildren[i];
12991282
}
13001283
return null;
13011284
},
@@ -1362,7 +1345,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
13621345
* If the cleanup parameter is not passed, it will force a cleanup. <br/>
13631346
* If the node orphan, then nothing happens.
13641347
* @function
1365-
* @param {Boolean} cleanup true if all actions and callbacks on this node should be removed, false otherwise.
1348+
* @param {Boolean} [cleanup=true] true if all actions and callbacks on this node should be removed, false otherwise.
13661349
* @see cc.Node#removeFromParentAndCleanup
13671350
*/
13681351
removeFromParent: function (cleanup) {
@@ -1377,7 +1360,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
13771360
* Removes this node itself from its parent node. <br/>
13781361
* If the node orphan, then nothing happens.
13791362
* @deprecated since v3.0, please use removeFromParent() instead
1380-
* @param {Boolean} cleanup true if all actions and callbacks on this node should be removed, false otherwise.
1363+
* @param {Boolean} [cleanup=true] true if all actions and callbacks on this node should be removed, false otherwise.
13811364
*/
13821365
removeFromParentAndCleanup: function (cleanup) {
13831366
cc.log(cc._LogInfos.Node_removeFromParentAndCleanup);
@@ -1391,7 +1374,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
13911374
* to override this method </p>
13921375
* @function
13931376
* @param {cc.Node} child The child node which will be removed.
1394-
* @param {Boolean|null} [cleanup=null] true if all running actions and callbacks on the child node will be cleanup, false otherwise.
1377+
* @param {Boolean} [cleanup=true] true if all running actions and callbacks on the child node will be cleanup, false otherwise.
13951378
*/
13961379
removeChild: function (child, cleanup) {
13971380
// explicit nil handling
@@ -1412,7 +1395,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
14121395
* If the cleanup parameter is not passed, it will force a cleanup. <br/>
14131396
* @function
14141397
* @param {Number} tag An integer number that identifies a child node
1415-
* @param {Boolean} cleanup true if all running actions and callbacks on the child node will be cleanup, false otherwise.
1398+
* @param {Boolean} [cleanup=true] true if all running actions and callbacks on the child node will be cleanup, false otherwise.
14161399
* @see cc.Node#removeChildByTag
14171400
*/
14181401
removeChildByTag: function (tag, cleanup) {
@@ -1428,7 +1411,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
14281411

14291412
/**
14301413
* Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
1431-
* @param {Boolean | null } cleanup
1414+
* @param {Boolean} [cleanup=true]
14321415
*/
14331416
removeAllChildrenWithCleanup: function (cleanup) {
14341417
//cc.log(cc._LogInfos.Node_removeAllChildrenWithCleanup); //TODO It should be discuss in v3.0
@@ -1439,7 +1422,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
14391422
* Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. <br/>
14401423
* If the cleanup parameter is not passed, it will force a cleanup. <br/>
14411424
* @function
1442-
* @param {Boolean | null } cleanup true if all running actions on all children nodes should be cleanup, false otherwise.
1425+
* @param {Boolean} [cleanup=true] true if all running actions on all children nodes should be cleanup, false otherwise.
14431426
*/
14441427
removeAllChildren: function (cleanup) {
14451428
// not using detachChild improves speed here
@@ -1477,7 +1460,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
14771460
}
14781461

14791462
// If you don't do cleanup, the child's actions will not get removed and the
1480-
// its scheduledSelectors_ dict will not get released!
14811463
if (doCleanup)
14821464
child.cleanup();
14831465

@@ -1578,7 +1560,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
15781560
onEnter: function () {
15791561
this._isTransitionFinished = false;
15801562
this._running = true;//should be running before resumeSchedule
1581-
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onEnter);
1563+
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onEnter);
15821564
this.resume();
15831565
},
15841566

@@ -1592,7 +1574,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
15921574
*/
15931575
onEnterTransitionDidFinish: function () {
15941576
this._isTransitionFinished = true;
1595-
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onEnterTransitionDidFinish);
1577+
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onEnterTransitionDidFinish);
15961578
},
15971579

15981580
/**
@@ -1602,7 +1584,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
16021584
* @function
16031585
*/
16041586
onExitTransitionDidStart: function () {
1605-
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onExitTransitionDidStart);
1587+
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onExitTransitionDidStart);
16061588
},
16071589

16081590
/**
@@ -1617,7 +1599,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
16171599
onExit: function () {
16181600
this._running = false;
16191601
this.pause();
1620-
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.onExit);
1602+
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.onExit);
16211603
this.removeAllComponents();
16221604
},
16231605

@@ -1631,7 +1613,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
16311613
* @return {cc.Action} An Action pointer
16321614
*/
16331615
runAction: function (action) {
1634-
16351616
cc.assert(action, cc._LogInfos.Node_runAction);
16361617

16371618
this.actionManager.addAction(action, this, !this._running);
@@ -1743,7 +1724,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
17431724
interval = interval || 0;
17441725

17451726
cc.assert(callback_fn, cc._LogInfos.Node_schedule);
1746-
17471727
cc.assert(interval >= 0, cc._LogInfos.Node_schedule_2);
17481728

17491729
repeat = (repeat == null) ? cc.REPEAT_FOREVER : repeat;
@@ -1770,7 +1750,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
17701750
* @param {function} callback_fn A function wrapped as a selector
17711751
*/
17721752
unschedule: function (callback_fn) {
1773-
// explicit nil handling
17741753
if (!callback_fn)
17751754
return;
17761755

@@ -2041,7 +2020,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
20412020
*/
20422021
updateTransform: function () {
20432022
// Recursively iterate over children
2044-
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._StateCallbackType.updateTransform);
2023+
this._arrayMakeObjectsPerformSelector(this._children, cc.Node._stateCallbackType.updateTransform);
20452024
},
20462025

20472026
/**
@@ -2117,27 +2096,27 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
21172096
this._componentContainer.removeAll();
21182097
},
21192098

2120-
//grid: null,
2099+
grid: null,
21212100

21222101
/**
21232102
* Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
21242103
* @function
21252104
*/
2126-
//ctor: null,
2105+
ctor: null,
21272106

21282107
/**
21292108
* Recursive method that visit its children and draw them
21302109
* @function
21312110
* @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx
21322111
*/
2133-
//visit: null,
2112+
visit: null,
21342113

21352114
/**
21362115
* Performs view-matrix transformation based on position, scale, rotation and other attributes.
21372116
* @function
21382117
* @param {CanvasRenderingContext2D|WebGLRenderingContext} ctx Render context
21392118
*/
2140-
//transform: null,
2119+
transform: null,
21412120

21422121
/**
21432122
* <p>Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.<br/>
@@ -2156,7 +2135,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
21562135
* @function
21572136
* @return {cc.AffineTransform} The affine transform object
21582137
*/
2159-
//getNodeToParentTransform: null,
2138+
getNodeToParentTransform: null,
21602139

21612140
_setNodeDirtyForCache: function () {
21622141
if (this._cacheDirty === false) {
@@ -2234,7 +2213,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
22342213
* It should be set in initialize phase.
22352214
* </p>
22362215
* @function
2237-
* @param {cc.GLProgram} newShaderProgram The shader program which fetchs from CCShaderCache.
2216+
* @param {cc.GLProgram} newShaderProgram The shader program which fetches from CCShaderCache.
22382217
* @example
22392218
* node.setGLProgram(cc.shaderCache.programForKey(cc.SHADER_POSITION_TEXTURECOLOR));
22402219
*/
@@ -2522,10 +2501,6 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
25222501
else
25232502
parentColor = cc.color.WHITE;
25242503
this.updateDisplayedColor(parentColor);
2525-
2526-
/*if (color.a !== undefined && !color.a_undefined) { //setColor doesn't support changing opacity, please use setOpacity
2527-
this.setOpacity(color.a);
2528-
}*/
25292504
},
25302505

25312506
/**
@@ -2629,7 +2604,7 @@ cc.Node.create = function () {
26292604
return new cc.Node();
26302605
};
26312606

2632-
cc.Node._StateCallbackType = {onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7};
2607+
cc.Node._stateCallbackType = {onEnter: 1, onExit: 2, cleanup: 3, onEnterTransitionDidFinish: 4, updateTransform: 5, onExitTransitionDidStart: 6, sortAllChildren: 7};
26332608

26342609
if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
26352610
//redefine cc.Node
@@ -2685,24 +2660,19 @@ if (cc._renderType === cc._RENDER_TYPE_CANVAS) {
26852660
};
26862661

26872662
_p._transformForRenderer = function () {
2688-
var t = this.nodeToParentTransform(), worldT = this._transformWorld;
2663+
var t = this.getNodeToParentTransform(), worldT = this._transformWorld;
26892664
if(this._parent){
26902665
var pt = this._parent._transformWorld;
26912666
//worldT = cc.AffineTransformConcat(t, pt);
26922667
worldT.a = t.a * pt.a + t.b * pt.c; //a
26932668
worldT.b = t.a * pt.b + t.b * pt.d; //b
26942669
worldT.c = t.c * pt.a + t.d * pt.c; //c
26952670
worldT.d = t.c * pt.b + t.d * pt.d; //d
2696-
if(!this._skewX || this._skewY){
2697-
var plt = this._parent._transform;
2698-
var xOffset = -(plt.b + plt.c) * t.ty ;
2699-
var yOffset = -(plt.b + plt.c) * t.tx;
2700-
worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx
2701-
worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty
2702-
}else{
2703-
worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx); //tx
2704-
worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty); //ty
2705-
}
2671+
var plt = this._parent._transform;
2672+
var xOffset = -(plt.b + plt.c) * t.ty;
2673+
var yOffset = -(plt.b + plt.c) * t.tx;
2674+
worldT.tx = (t.tx * pt.a + t.ty * pt.c + pt.tx + xOffset); //tx
2675+
worldT.ty = (t.tx * pt.b + t.ty * pt.d + pt.ty + yOffset); //ty
27062676
} else {
27072677
worldT.a = t.a;
27082678
worldT.b = t.b;

0 commit comments

Comments
 (0)