issue #1549: Sync jsb_constants_cocos2d.js and jsb_constants_cocosbuilder.js to -iphone version.

This commit is contained in:
James Chen 2012-11-05 18:43:12 +08:00
parent 270676b74d
commit b72f922287
2 changed files with 43 additions and 38 deletions

View File

@ -283,20 +283,26 @@ cc.dumpConfig = function () {
// Bindings Overrides // Bindings Overrides
// //
// MenuItemToggle // MenuItemToggle
cc.MenuItemToggle.create = function (/* var args */) { cc.MenuItemToggle.create = function( /* var args */) {
var n = arguments.length; var n = arguments.length;
if (typeof arguments[n - 1] === 'function') { if (typeof arguments[n-2] === 'function' || typeof arguments[n-1] === 'function') {
var args = Array.prototype.slice.call(arguments); var args = Array.prototype.slice.call(arguments);
var obj = null;
if( typeof arguments[n-2] === 'function' )
obj = args.pop();
var func = args.pop(); var func = args.pop();
var obj = args.pop();
// create it with arguments, // create it with arguments,
var item = cc.MenuItemToggle._create.apply(this, args); var item = cc.MenuItemToggle._create.apply(this, args);
// then set the callback // then set the callback
item.setCallback(obj, func); if( obj !== null )
item.setCallback(func, obj);
else
item.setCallback(func);
return item; return item;
} else { } else {
return cc.MenuItemToggle._create.apply(this, arguments); return cc.MenuItemToggle._create.apply(this, arguments);
@ -304,17 +310,16 @@ cc.MenuItemToggle.create = function (/* var args */) {
}; };
// LabelAtlas // LabelAtlas
// TODO: cc.LabelAtlas.create = function( a,b,c,d,e ) {
// cc.LabelAtlas.create = function (a, b, c, d, e) {
// var n = arguments.length; var n = arguments.length;
// if (n == 5) { if ( n == 5) {
// return cc.LabelAtlas._create(a, b, c, d, e.charCodeAt(0)); return cc.LabelAtlas._create(a,b,c,d,e.charCodeAt(0));
// } else { } else {
// return cc.LabelAtlas._create.apply(this, arguments); return cc.LabelAtlas._create.apply(this, arguments);
// } }
// }; };
/** /**
* Associates a base class with a native superclass * Associates a base class with a native superclass

View File

@ -11,7 +11,7 @@ cc.Reader.load = function(file, owner, parentSize)
// Load the node graph using the correct function // Load the node graph using the correct function
var reader = cc._Reader.create(); var reader = cc._Reader.create();
var node; var node;
if (owner && parentSize) if (owner && parentSize)
{ {
node = reader.load(file, owner, parentSize); node = reader.load(file, owner, parentSize);
@ -24,87 +24,87 @@ cc.Reader.load = function(file, owner, parentSize)
{ {
node = reader.load(file); node = reader.load(file);
} }
// Assign owner callbacks & member variables // Assign owner callbacks & member variables
if (owner) if (owner)
{ {
// Callbacks // Callbacks
var ownerCallbackNames = reader.getOwnerCallbackNames(); var ownerCallbackNames = reader.getOwnerCallbackNames();
var ownerCallbackNodes = reader.getOwnerCallbackNodes(); var ownerCallbackNodes = reader.getOwnerCallbackNodes();
for (var i = 0; i < ownerCallbackNames.length; i++) for (var i = 0; i < ownerCallbackNames.length; i++)
{ {
var callbackName = ownerCallbackNames[i]; var callbackName = ownerCallbackNames[i];
var callbackNode = ownerCallbackNodes[i]; var callbackNode = ownerCallbackNodes[i];
callbackNode.setCallback(owner, owner[callbackName]); callbackNode.setCallback(owner[callbackName], owner);
} }
// Variables // Variables
var ownerOutletNames = reader.getOwnerOutletNames(); var ownerOutletNames = reader.getOwnerOutletNames();
var ownerOutletNodes = reader.getOwnerOutletNodes(); var ownerOutletNodes = reader.getOwnerOutletNodes();
for (var i = 0; i < ownerOutletNames.length; i++) for (var i = 0; i < ownerOutletNames.length; i++)
{ {
var outletName = ownerOutletNames[i]; var outletName = ownerOutletNames[i];
var outletNode = ownerOutletNodes[i]; var outletNode = ownerOutletNodes[i];
owner[outletName] = outletNode; owner[outletName] = outletNode;
} }
} }
var nodesWithAnimationManagers = reader.getNodesWithAnimationManagers(); var nodesWithAnimationManagers = reader.getNodesWithAnimationManagers();
var animationManagersForNodes = reader.getAnimationManagersForNodes(); var animationManagersForNodes = reader.getAnimationManagersForNodes();
// Attach animation managers to nodes and assign root node callbacks and member variables // Attach animation managers to nodes and assign root node callbacks and member variables
for (var i = 0; i < nodesWithAnimationManagers.length; i++) for (var i = 0; i < nodesWithAnimationManagers.length; i++)
{ {
var innerNode = nodesWithAnimationManagers[i]; var innerNode = nodesWithAnimationManagers[i];
var animationManager = animationManagersForNodes[i]; var animationManager = animationManagersForNodes[i];
innerNode.animationManager = animationManager; innerNode.animationManager = animationManager;
var documentControllerName = animationManager.getDocumentControllerName(); var documentControllerName = animationManager.getDocumentControllerName();
if (!documentControllerName) continue; if (!documentControllerName) continue;
// Create a document controller // Create a document controller
var controller = new _ccbGlobalContext[documentControllerName](); var controller = new _ccbGlobalContext[documentControllerName]();
controller.controllerName = documentControllerName; controller.controllerName = documentControllerName;
innerNode.controller = controller; innerNode.controller = controller;
controller.rootNode = innerNode; controller.rootNode = innerNode;
// Callbacks // Callbacks
var documentCallbackNames = animationManager.getDocumentCallbackNames(); var documentCallbackNames = animationManager.getDocumentCallbackNames();
var documentCallbackNodes = animationManager.getDocumentCallbackNodes(); var documentCallbackNodes = animationManager.getDocumentCallbackNodes();
for (var j = 0; j < documentCallbackNames.length; j++) for (var j = 0; j < documentCallbackNames.length; j++)
{ {
var callbackName = documentCallbackNames[j]; var callbackName = documentCallbackNames[j];
var callbackNode = documentCallbackNodes[j]; var callbackNode = documentCallbackNodes[j];
callbackNode.setCallback(controller, controller[callbackName]); callbackNode.setCallback(controller[callbackName], controller);
} }
// Variables // Variables
var documentOutletNames = animationManager.getDocumentOutletNames(); var documentOutletNames = animationManager.getDocumentOutletNames();
var documentOutletNodes = animationManager.getDocumentOutletNodes(); var documentOutletNodes = animationManager.getDocumentOutletNodes();
for (var j = 0; j < documentOutletNames.length; j++) for (var j = 0; j < documentOutletNames.length; j++)
{ {
var outletName = documentOutletNames[j]; var outletName = documentOutletNames[j];
var outletNode = documentOutletNodes[j]; var outletNode = documentOutletNodes[j];
controller[outletName] = outletNode; controller[outletName] = outletNode;
} }
if (typeof(controller.onDidLoadFromCCB) == "function") if (typeof(controller.onDidLoadFromCCB) == "function")
{ {
controller.onDidLoadFromCCB(); controller.onDidLoadFromCCB();
} }
} }
return node; return node;
} }
@ -113,6 +113,6 @@ cc.Reader.loadAsScene = function(file, owner, parentSize)
var node = cc.Reader.load(file, owner, parentSize); var node = cc.Reader.load(file, owner, parentSize);
var scene = cc.Scene.create(); var scene = cc.Scene.create();
scene.addChild( node ); scene.addChild( node );
return scene; return scene;
} }