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
//
// MenuItemToggle
cc.MenuItemToggle.create = function (/* var args */) {
cc.MenuItemToggle.create = function( /* var args */) {
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 obj = null;
if( typeof arguments[n-2] === 'function' )
obj = args.pop();
var func = args.pop();
var obj = args.pop();
// create it with arguments,
var item = cc.MenuItemToggle._create.apply(this, args);
// then set the callback
item.setCallback(obj, func);
if( obj !== null )
item.setCallback(func, obj);
else
item.setCallback(func);
return item;
} else {
return cc.MenuItemToggle._create.apply(this, arguments);
@ -304,17 +310,16 @@ cc.MenuItemToggle.create = function (/* var args */) {
};
// 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) {
// return cc.LabelAtlas._create(a, b, c, d, e.charCodeAt(0));
// } else {
// return cc.LabelAtlas._create.apply(this, arguments);
// }
// };
if ( n == 5) {
return cc.LabelAtlas._create(a,b,c,d,e.charCodeAt(0));
} else {
return cc.LabelAtlas._create.apply(this, arguments);
}
};
/**
* 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
var reader = cc._Reader.create();
var node;
if (owner && parentSize)
{
node = reader.load(file, owner, parentSize);
@ -24,87 +24,87 @@ cc.Reader.load = function(file, owner, parentSize)
{
node = reader.load(file);
}
// Assign owner callbacks & member variables
if (owner)
{
// Callbacks
var ownerCallbackNames = reader.getOwnerCallbackNames();
var ownerCallbackNodes = reader.getOwnerCallbackNodes();
for (var i = 0; i < ownerCallbackNames.length; i++)
{
var callbackName = ownerCallbackNames[i];
var callbackNode = ownerCallbackNodes[i];
callbackNode.setCallback(owner, owner[callbackName]);
callbackNode.setCallback(owner[callbackName], owner);
}
// Variables
var ownerOutletNames = reader.getOwnerOutletNames();
var ownerOutletNodes = reader.getOwnerOutletNodes();
for (var i = 0; i < ownerOutletNames.length; i++)
{
var outletName = ownerOutletNames[i];
var outletNode = ownerOutletNodes[i];
owner[outletName] = outletNode;
}
}
var nodesWithAnimationManagers = reader.getNodesWithAnimationManagers();
var animationManagersForNodes = reader.getAnimationManagersForNodes();
// Attach animation managers to nodes and assign root node callbacks and member variables
for (var i = 0; i < nodesWithAnimationManagers.length; i++)
{
var innerNode = nodesWithAnimationManagers[i];
var animationManager = animationManagersForNodes[i];
innerNode.animationManager = animationManager;
var documentControllerName = animationManager.getDocumentControllerName();
if (!documentControllerName) continue;
// Create a document controller
var controller = new _ccbGlobalContext[documentControllerName]();
controller.controllerName = documentControllerName;
innerNode.controller = controller;
controller.rootNode = innerNode;
// Callbacks
var documentCallbackNames = animationManager.getDocumentCallbackNames();
var documentCallbackNodes = animationManager.getDocumentCallbackNodes();
for (var j = 0; j < documentCallbackNames.length; j++)
{
var callbackName = documentCallbackNames[j];
var callbackNode = documentCallbackNodes[j];
callbackNode.setCallback(controller, controller[callbackName]);
callbackNode.setCallback(controller[callbackName], controller);
}
// Variables
var documentOutletNames = animationManager.getDocumentOutletNames();
var documentOutletNodes = animationManager.getDocumentOutletNodes();
for (var j = 0; j < documentOutletNames.length; j++)
{
var outletName = documentOutletNames[j];
var outletNode = documentOutletNodes[j];
controller[outletName] = outletNode;
}
if (typeof(controller.onDidLoadFromCCB) == "function")
{
controller.onDidLoadFromCCB();
}
}
return node;
}
@ -113,6 +113,6 @@ cc.Reader.loadAsScene = function(file, owner, parentSize)
var node = cc.Reader.load(file, owner, parentSize);
var scene = cc.Scene.create();
scene.addChild( node );
return scene;
}