diff --git a/extensions/CCBReader/CCData.h b/extensions/CCBReader/CCData.h index 68814ca7be..127b6a69c0 100644 --- a/extensions/CCBReader/CCData.h +++ b/extensions/CCBReader/CCData.h @@ -3,7 +3,7 @@ #define __CCB_CCDATA_H__ #include "cocos2d.h" -#include "cocos-ext.h" +#include "ExtensionMacros.h"" NS_CC_EXT_BEGIN diff --git a/scripting/javascript/bindings/js_bindings_ccbreader.cpp b/scripting/javascript/bindings/js_bindings_ccbreader.cpp index 0e4ae90323..50e7e98a35 100644 --- a/scripting/javascript/bindings/js_bindings_ccbreader.cpp +++ b/scripting/javascript/bindings/js_bindings_ccbreader.cpp @@ -13,10 +13,19 @@ USING_NS_CC; USING_NS_CC_EXT; +static void removeSelector(std::string &str) { + size_t found; + found = str.find(":"); + while (found!=std::string::npos){ + str.replace(found, found+1, ""); + found = str.find(":"); + } +} SEL_MenuHandler CCBScriptCallbackProxy::onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName) { this->callBackProp = pSelectorName->getCString(); + removeSelector(this->callBackProp); return menu_selector(CCBScriptCallbackProxy::menuItemCallback); } @@ -24,12 +33,14 @@ SEL_CCControlHandler CCBScriptCallbackProxy::onResolveCCBCCControlSelector(CCObj CCString * pSelectorName) { this->callBackProp = pSelectorName->getCString(); + removeSelector(this->callBackProp); return cccontrol_selector(CCBScriptCallbackProxy::controlCallback); } bool CCBScriptCallbackProxy::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) { + return true; } void CCBScriptCallbackProxy::onNodeLoaded(CCNode * pNode, @@ -81,11 +92,8 @@ static CCNode* loadReader(const char *file, jsval owner) { //ccbReader->setOwner(dynamic_cast(ccBCallbackProxy)); CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(ccBCallbackProxy); - if(targetAsCCBSelectorResolver != NULL) { - js_log("NOT NULL"); - } - CCNode * node = ccbReader->readNodeGraphFromFile("./", file, dynamic_cast(ccBCallbackProxy)); + CCNode * node = ccbReader->readNodeGraphFromFile(file, dynamic_cast(ccBCallbackProxy)); return node; } diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-hd.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-hd.png.REMOVED.git-id new file mode 100644 index 0000000000..18b9c22de9 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-hd.png.REMOVED.git-id @@ -0,0 +1 @@ +f06c047dd32b61f12ad51e981afe518364512be6 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-ipad.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-ipad.png.REMOVED.git-id new file mode 100644 index 0000000000..717ceb89a1 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40-ipad.png.REMOVED.git-id @@ -0,0 +1 @@ +4b7c1e97acefff48ae3652f023e708245992f553 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40.png.REMOVED.git-id new file mode 100644 index 0000000000..fb1884455b --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Abadi40.png.REMOVED.git-id @@ -0,0 +1 @@ +ae62d7b07ac3e7579ed7d6a2e1f903719e45c6d9 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-hd.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-hd.png.REMOVED.git-id new file mode 100644 index 0000000000..5067e00b74 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-hd.png.REMOVED.git-id @@ -0,0 +1 @@ +12db20c3124e1bd864312257eb8cefe95d2ee349 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-ipad.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-ipad.png.REMOVED.git-id new file mode 100644 index 0000000000..8ddebffce2 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/Gas40-ipad.png.REMOVED.git-id @@ -0,0 +1 @@ +e71140c1535f16b49980f3ea0cf7d3a29a8a9788 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-hd.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-hd.png.REMOVED.git-id new file mode 100644 index 0000000000..15f23ffc85 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-hd.png.REMOVED.git-id @@ -0,0 +1 @@ +dc235c169030151e337ecbfa1fc6302fc909e500 \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-ipad.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-ipad.png.REMOVED.git-id new file mode 100644 index 0000000000..2549ab6362 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32-ipad.png.REMOVED.git-id @@ -0,0 +1 @@ +9e95a02e6eb2944fea12a49eb3f2c6fe7505a3ce \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32.png.REMOVED.git-id b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32.png.REMOVED.git-id new file mode 100644 index 0000000000..83954562c0 --- /dev/null +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/CCB/konqa32.png.REMOVED.git-id @@ -0,0 +1 @@ +1423c81273926b3da9fb1cb36c9b710d3f14ee0e \ No newline at end of file diff --git a/template/xcode4/cocos2dx_js.xctemplate/Resources/hello.js b/template/xcode4/cocos2dx_js.xctemplate/Resources/hello.js index 3e737b8ca6..0d77bcec6d 100644 --- a/template/xcode4/cocos2dx_js.xctemplate/Resources/hello.js +++ b/template/xcode4/cocos2dx_js.xctemplate/Resources/hello.js @@ -1,5 +1,6 @@ + try { - + cc.p = cc.p || function( x, y ) { return {x:x, y:y}; }; @@ -7,23 +8,140 @@ try { cc.c4b = cc.c4 || function (r, g, b, o) { return {r: r, g: g, b: b, a: o}; }; + + + cc.c3 = cc.c3 || function (r, g, b) { + return {r: r, g: g, b: b}; + }; + cc.BLACK = cc.c3(0,0,0); + director = cc.Director.getInstance(); winSize = director.getWinSize(); + centerPos = cc.p( winSize.width/2, winSize.height/2 ); - var scene = new cc.Scene(); - var layer = new cc.LayerGradient(); + var GameCreator = function() { + + var self = {}; + self.callbacks = {}; + + self.getPlayScene = function() { + + var scene = new cc.Scene(); + var layer = new cc.LayerGradient(); + + layer.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); + + var lab = "Houston we have liftoff!"; + var label = cc.LabelTTF.create(lab, "Arial", 28); + layer.addChild(label, 1); + label.setPosition( cc.p(winSize.width / 2, winSize.height / 2)); + + var back = cc.MenuItemFont.create("Back", this.callbacks, this.callbacks.onBack ); + back.setColor( cc.BLACK ); + + var menu = cc.Menu.create( back ); + layer.addChild( menu ); + menu.alignItemsVertically(); + menu.setPosition( cc.p( winSize.width - 50, 50) ); + + scene.addChild(layer); + + return scene; + }; + + self.getMainMenuScene = function() { + var l = cc.Layer.create(); + var scene = cc.Scene.create(); + + var node = cc.Reader.load("MainMenu.ccbi", this, winSize); + l.addChild(node); + + scene.addChild(l); + + return scene; + }; + + self.getOptionsScene = function() { + + var l = cc.LayerGradient.create(); + l.init(cc.c4b(0, 0, 0, 255), cc.c4b(255, 255, 255, 255)); + + var scene = cc.Scene.create(); + + var label1 = cc.LabelBMFont.create("MUSIC ON", "konqa32.fnt" ); + var item1 = cc.MenuItemLabel.create(label1); + var label2 = cc.LabelBMFont.create("MUSIC OFF", "konqa32.fnt" ); + var item2 = cc.MenuItemLabel.create(label2); + var toggle = cc.MenuItemToggle.create( item1, item2 ); + + this.onMusicToggle = function( sender ) { + }; + + toggle.setCallback( this, this.onMusicToggle); + + var back = cc.MenuItemFont.create("Back", this.callbacks, this.callbacks.onBack ); + var menu = cc.Menu.create( toggle, back ); + l.addChild( menu ); + menu.alignItemsVertically(); + menu.setPosition( centerPos ); + + scene.addChild(l); + + return scene; + }; + + + self.getAboutScene = function() { + + var scene = cc.Scene.create(); + var l = cc.Layer.create(); + var about = cc.Reader.load("About.ccbi", this); + l.addChild( about ) + + var back = cc.MenuItemFont.create("Back", this.callbacks, this.callbacks.onBack ); + back.setColor( cc.BLACK ); + var menu = cc.Menu.create( back ); + l.addChild( menu ); + menu.alignItemsVertically(); + menu.setPosition( cc.p( winSize.width - 50, 50) ); + + scene.addChild( l ); + + return scene; + }; + + + // CCBuilder Selectors + + self.onPlay = function() { + director.replaceScene( cc.TransitionFade.create(1, this.getPlayScene()) ); + } + + self.onAbout = function() { + director.replaceScene( cc.TransitionZoomFlipY.create(1, this.getAboutScene()) ); + }; - layer.init(cc.c4b(0, 0, 0, 255), cc.c4b(0, 128, 255, 255)); + self.onOptions = function() { + director.replaceScene( cc.TransitionZoomFlipY.create(1, this.getOptionsScene()) ); + }; + + + // Manual Callbacks + + self.callbacks.onBack = function( sender) { + director.replaceScene( cc.TransitionFlipX.create(1, self.getMainMenuScene()) ); + }; + + return self; - var lab = "Houston we have liftoff!"; - var label = cc.LabelTTF.create(lab, "Arial", 28); - layer.addChild(label, 1); - label.setPosition( cc.p(winSize.width / 2, winSize.height / 2)); + }; + + var game = GameCreator(); + + __jsc__.garbageCollect(); + + director.runWithScene(game.getMainMenuScene()); + +} catch(e) {log(e);} - - scene.addChild(layer); - - director.runWithScene(scene); - -} catch(e) {log(e);} \ No newline at end of file