diff --git a/extensions/CCBReader/CCBAnimationManager.cpp b/extensions/CCBReader/CCBAnimationManager.cpp index 092572567d..a879058590 100644 --- a/extensions/CCBReader/CCBAnimationManager.cpp +++ b/extensions/CCBReader/CCBAnimationManager.cpp @@ -71,6 +71,11 @@ CCArray* CCBAnimationManager::getSequences() return mSequences; } +void CCBAnimationManager::setSequences(CCArray* seq) +{ + mSequences = seq; +} + int CCBAnimationManager::getAutoPlaySequenceId() { return mAutoPlaySequenceId; diff --git a/extensions/CCBReader/CCBAnimationManager.h b/extensions/CCBReader/CCBAnimationManager.h index 9f1aa7a52a..98aa46b99e 100644 --- a/extensions/CCBReader/CCBAnimationManager.h +++ b/extensions/CCBReader/CCBAnimationManager.h @@ -39,6 +39,7 @@ private: SEL_CallFunc mAnimationCompleteCallbackFunc; CCObject *mTarget; + public: CCBAnimationManager(); ~CCBAnimationManager(); @@ -46,6 +47,8 @@ public: virtual bool init(); CCArray* getSequences(); + void setSequences(CCArray* seq); + int getAutoPlaySequenceId(); void setAutoPlaySequenceId(int autoPlaySequenceId); diff --git a/extensions/CCBReader/CCBReader.cpp b/extensions/CCBReader/CCBReader.cpp index 59cbf6fe41..be22ee8bbc 100644 --- a/extensions/CCBReader/CCBReader.cpp +++ b/extensions/CCBReader/CCBReader.cpp @@ -252,6 +252,7 @@ CCNode* CCBReader::readNodeGraphFromData(CCData *pData, CCObject *pOwner, const } for(int i = 0; i < mAnimationManagers.size(); ++i) { + mAnimationManagers[i].first->setUserObject(mAnimationManagers[i].second); if(jsControlled) { mNodesWithAnimationManagers->addObject(mAnimationManagers[i].first); mAnimationManagerForNodes->addObject(mAnimationManagers[i].second); diff --git a/extensions/CCBReader/CCNodeLoader.cpp b/extensions/CCBReader/CCNodeLoader.cpp index b7d6954bb6..ff4fd402a5 100644 --- a/extensions/CCBReader/CCNodeLoader.cpp +++ b/extensions/CCBReader/CCNodeLoader.cpp @@ -35,13 +35,13 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * { setProp = true; } -#ifdef __CC_PLATFORM_IOS - if(platform == kCCBPlatformIOS) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + if(platform == kCCBPlatformIOS) { setProp = true; } -#elif defined(__CC_PLATFORM_MAC) - if(platform == kCCBPlatformMac) +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) + if(platform == kCCBPlatformMac) { setProp = true; } diff --git a/scripting/javascript/bindings/Android.mk b/scripting/javascript/bindings/Android.mk index 3cdb666b3f..04422fcf77 100644 --- a/scripting/javascript/bindings/Android.mk +++ b/scripting/javascript/bindings/Android.mk @@ -15,6 +15,7 @@ LOCAL_SRC_FILES := ScriptingCore.cpp \ js_bindings_chipmunk_functions.cpp \ js_bindings_chipmunk_auto_classes.cpp \ js_bindings_chipmunk_registration.cpp \ + js_bindings_ccbreader.cpp \ js_bindings_core.cpp \ generated/cocos2dx.cpp diff --git a/scripting/javascript/bindings/cocos2d_specifics.cpp b/scripting/javascript/bindings/cocos2d_specifics.cpp index a1ab3e63f3..851b751817 100644 --- a/scripting/javascript/bindings/cocos2d_specifics.cpp +++ b/scripting/javascript/bindings/cocos2d_specifics.cpp @@ -1158,6 +1158,45 @@ JSBool js_cocos2dx_release(JSContext *cx, uint32_t argc, jsval *vp) return JS_FALSE; } + +JSBool js_cocos2dx_CCNode_removeChild(JSContext *cx, uint32_t argc, jsval *vp) +{ + jsval *argv = JS_ARGV(cx, vp); + JSObject *obj = JS_THIS_OBJECT(cx, vp); + js_proxy_t *proxy; JS_GET_NATIVE_PROXY(proxy, obj); + cocos2d::CCNode* cobj = (cocos2d::CCNode *)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, cobj) + + if (argc == 2) { + cocos2d::CCNode* arg0; + JSBool arg1; + do { + js_proxy_t *proxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + JS_GET_NATIVE_PROXY(proxy, tmpObj); + arg0 = (cocos2d::CCNode*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg0) + } while (0); + JS_ValueToBoolean(cx, argv[1], &arg1); + cobj->removeChild(arg0, arg1); + return JS_TRUE; + } else if(argc == 1) { + cocos2d::CCNode* arg0; + do { + js_proxy_t *proxy; + JSObject *tmpObj = JSVAL_TO_OBJECT(argv[0]); + JS_GET_NATIVE_PROXY(proxy, tmpObj); + arg0 = (cocos2d::CCNode*)(proxy ? proxy->ptr : NULL); + TEST_NATIVE_OBJECT(cx, arg0) + } while (0); + cobj->removeChild(arg0, true); + return JS_TRUE; + } + + JS_ReportError(cx, "wrong number of arguments: %d, was expecting %d", argc, 2); + return JS_FALSE; +} + JSBool js_cocos2dx_CCSet_constructor(JSContext *cx, uint32_t argc, jsval *vp) { JSObject *obj; @@ -2032,6 +2071,7 @@ void register_cocos2dx_js_extensions(JSContext* cx, JSObject* global) JS_DefineFunction(cx, js_cocos2dx_CCNode_prototype, "retain", js_cocos2dx_retain, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, js_cocos2dx_CCNode_prototype, "release", js_cocos2dx_release, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(cx, js_cocos2dx_CCNode_prototype, "removeChild", js_cocos2dx_CCNode_removeChild, 0, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, js_cocos2dx_CCSprite_prototype, "setBlendFunc", js_cocos2dx_CCSprite_setBlendFunc, 2, JSPROP_READONLY | JSPROP_PERMANENT); JS_DefineFunction(cx, js_cocos2dx_CCSpriteBatchNode_prototype, "setBlendFunc", js_cocos2dx_CCSpriteBatchNode_setBlendFunc, 2, JSPROP_READONLY | JSPROP_PERMANENT); diff --git a/tools/tojs/cocos2dx.ini b/tools/tojs/cocos2dx.ini index 4b36a6b601..e214ad514c 100644 --- a/tools/tojs/cocos2dx.ini +++ b/tools/tojs/cocos2dx.ini @@ -35,7 +35,7 @@ classes = CCSprite.* CCScene CCNode CCDirector CCLayer.* CCMenu.* CCTouch CC.*Ac # will apply to all class names. This is a convenience wildcard to be able to skip similar named # functions from all classes. -skip = CCNode::[.*Transform convertToWindowSpace getChildren setPosition getGrid setGLServerState description getShaderProgram getUserObject .*UserData getGLServerState unscheduleAllSelectors], +skip = CCNode::[.*Transform convertToWindowSpace getChildren setPosition getGrid setGLServerState description getShaderProgram getUserObject .*UserData getGLServerState removeChild$ unscheduleAllSelectors], CCSprite::[getQuad displayFrame getBlendFunc setPosition setBlendFunc setSpriteBatchNode getSpriteBatchNode], CCSpriteBatchNode::[getBlendFunc setBlendFunc], CCMotionStreak::[getBlendFunc setBlendFunc], @@ -96,7 +96,7 @@ skip = CCNode::[.*Transform convertToWindowSpace getChildren setPosition getGrid CCCardinalSpline.*::[create actionWithDuration setPoints], CCScheduler::[pause resume unscheduleAllSelectorsForTarget], CCTextureCache::[addPVRTCImage], - CCTimer::[getSelector], + CCTimer::[getSelector], CC.*Loader$::[*], *::[copyWith.* onEnter.* onExit.* description getObjectType .*RGB.* .*HSV.*] @@ -124,8 +124,6 @@ rename_functions = CCDirector::[sharedDirector=getInstance], CCTMXTiledMap::[layerNamed=getLayer objectGroupNamed=getObjectGroup propertyNamed=getProperty], CCUserDefault::[sharedUserDefault=getInstance] - - rename_classes = CCParticleSystemQuad::CCParticleSystem, SimpleAudioEngine::AudioEngine, CCBReader::CC_Reader,