From 2b19da00df799676d65b82154b0bff6f5c040f15 Mon Sep 17 00:00:00 2001 From: samuele3hu Date: Fri, 3 Jan 2014 14:51:36 +0800 Subject: [PATCH] Update the lua test cases about the armature --- cocos/2d/cocos2d.h | 1 + .../lua_cocos2dx_coco_studio_manual.cpp | 82 ++++--- cocos/scripting/lua/script/Deprecated.lua | 15 -- .../CocoStudioArmatureTest.lua | 202 ++++++++++++------ 4 files changed, 178 insertions(+), 122 deletions(-) diff --git a/cocos/2d/cocos2d.h b/cocos/2d/cocos2d.h index 1dfdcba511..fceec68f6a 100644 --- a/cocos/2d/cocos2d.h +++ b/cocos/2d/cocos2d.h @@ -111,6 +111,7 @@ THE SOFTWARE. #include "CCMotionStreak.h" #include "CCProgressTimer.h" #include "CCRenderTexture.h" +#include "CCNodeGrid.h" // particle_nodes #include "CCParticleBatchNode.h" diff --git a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp index c0459ea85a..affd70c634 100644 --- a/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp +++ b/cocos/scripting/lua/bindings/lua_cocos2dx_coco_studio_manual.cpp @@ -23,8 +23,6 @@ public: LuaArmatureWrapper(); virtual ~LuaArmatureWrapper(); - virtual void movementEventCallback(Armature* armature, MovementEventType type,const char* movementID); - virtual void frameEventCallback(Bone* bone, const char* frameEventName, int orginFrameIndex, int currentFrameIndex); virtual void addArmatureFileInfoAsyncCallback(float percent); }; @@ -38,41 +36,6 @@ LuaArmatureWrapper::~LuaArmatureWrapper() } -void LuaArmatureWrapper::movementEventCallback(Armature* armature, MovementEventType type,const char* movementID) -{ - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); - - if (0 != handler) - { - std::string strMovementID = movementID; - LuaArmatureMovementEventData movementData(armature,(int)type, strMovementID); - - LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::MOVEMENT_EVENT , (void*)&movementData); - - BasicScriptData data(this,(void*)&wrapperData); - - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data); - } -} - -void LuaArmatureWrapper::frameEventCallback(Bone* bone, const char* frameEventName, int orginFrameIndex, int currentFrameIndex) -{ - int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); - - if (0 != handler) - { - std::string strFrameEventName(frameEventName); - - LuaArmatureFrameEventData frameData(bone,strFrameEventName,orginFrameIndex,currentFrameIndex); - - LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FRAME_EVENT , (void*)&frameData); - - BasicScriptData data(this,(void*)&wrapperData); - - LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data); - } -} - void LuaArmatureWrapper::addArmatureFileInfoAsyncCallback(float percent) { int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)this, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); @@ -124,11 +87,25 @@ static int lua_cocos2dx_ArmatureAnimation_setMovementEventCallFunc(lua_State* L) LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); wrapper->autorelease(); + Vector vec; + vec.pushBack(wrapper); ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); - - self->setUserObject(wrapper); - self->setMovementEventCallFunc(wrapper, movementEvent_selector(LuaArmatureWrapper::movementEventCallback)); - + + self->setMovementEventCallFunc([=](Armature *armature, MovementEventType movementType, const std::string& movementID){ + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)vec.at(0), ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + if (0 != handler) + { + std::string strMovementID = movementID; + LuaArmatureMovementEventData movementData(armature,(int)movementType, strMovementID); + + LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::MOVEMENT_EVENT , (void*)&movementData); + + BasicScriptData data((void*)vec.at(0),(void*)&wrapperData); + + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data); + } + }); return 0; } @@ -180,10 +157,27 @@ static int lua_cocos2dx_ArmatureAnimation_setFrameEventCallFunc(lua_State* L) LuaArmatureWrapper* wrapper = new LuaArmatureWrapper(); wrapper->autorelease(); - ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + Vector vec; + vec.pushBack(wrapper); - self->setUserObject(wrapper); - self->setFrameEventCallFunc(wrapper, frameEvent_selector(LuaArmatureWrapper::frameEventCallback)); + ScriptHandlerMgr::getInstance()->addObjectHandler((void*)wrapper, handler, ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + self->setFrameEventCallFunc([=](Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex){ + int handler = ScriptHandlerMgr::getInstance()->getObjectHandler((void*)vec.at(0), ScriptHandlerMgr::HandlerType::ARMATURE_EVENT); + + if (0 != handler) + { + std::string strFrameEventName(frameEventName); + + LuaArmatureFrameEventData frameData(bone,frameEventName,originFrameIndex,currentFrameIndex); + + LuaArmatureWrapperEventData wrapperData(LuaArmatureWrapperEventData::LuaArmatureWrapperEventType::FRAME_EVENT , (void*)&frameData); + + BasicScriptData data((void*)vec.at(0),(void*)&wrapperData); + + LuaEngine::getInstance()->handleEvent(ScriptHandlerMgr::HandlerType::ARMATURE_EVENT, (void*)&data); + } + }); return 0; } diff --git a/cocos/scripting/lua/script/Deprecated.lua b/cocos/scripting/lua/script/Deprecated.lua index 01ce6f62a7..391c47238a 100644 --- a/cocos/scripting/lua/script/Deprecated.lua +++ b/cocos/scripting/lua/script/Deprecated.lua @@ -1088,21 +1088,6 @@ end rawset(SceneReader,"purgeSceneReader",SceneReaderDeprecated.purgeSceneReader) --functions of SceneReader will be deprecated end ---functions of ActionManager will be deprecated begin -local ActionManagerDeprecated = { } -function ActionManagerDeprecated.shareManager() - deprecatedTip("ActionManager:shareManager","ccs.ActionManagerEx:getInstance") - return ccs.ActionManagerEx:getInstance() -end -rawset(ActionManager,"shareManager",ActionManagerDeprecated.shareManager) - -function ActionManagerDeprecated.destroyInstance() - deprecatedTip("ActionManager:destroyInstance","ccs.ActionManagerEx:destroyActionManager") - return ccs.ActionManagerEx:destroyActionManager() -end -rawset(ActionManager,"destroyInstance",ActionManagerDeprecated.destroyInstance) ---functions of ActionManager will be deprecated end - --functions of CCEGLView will be deprecated begin local CCEGLViewDeprecated = { } function CCEGLViewDeprecated.sharedOpenGLView() diff --git a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua index 7531500dc8..d47b24034e 100644 --- a/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua +++ b/samples/Lua/TestLua/Resources/luaScript/CocoStudioTest/CocoStudioArmatureTest/CocoStudioArmatureTest.lua @@ -10,15 +10,14 @@ local ArmatureTestIndex = TEST_COCOSTUDIO_WITH_SKELETON = 3, TEST_DRAGON_BONES_2_0 = 4, TEST_PERFORMANCE = 5, - TEST_PERFORMANCE_BATCHNODE = 6, - TEST_CHANGE_ZORDER = 7, - TEST_ANIMATION_EVENT = 8, - TEST_FRAME_EVENT = 9, - TEST_PARTICLE_DISPLAY = 10, - TEST_USE_DIFFERENT_PICTURE = 11, - TEST_ANCHORPOINT = 12, - TEST_ARMATURE_NESTING = 13, - TEST_ARMATURE_NESTING_2 = 14, + TEST_CHANGE_ZORDER = 6, + TEST_ANIMATION_EVENT = 7, + TEST_FRAME_EVENT = 8, + TEST_PARTICLE_DISPLAY = 9, + TEST_USE_DIFFERENT_PICTURE = 10, + TEST_ANCHORPOINT = 11, + TEST_ARMATURE_NESTING = 12, + TEST_ARMATURE_NESTING_2 = 13, } local armatureSceneIdx = ArmatureTestIndex.TEST_ASYNCHRONOUS_LOADING @@ -80,8 +79,6 @@ function ArmatureTestLayer.title(idx) return "Test Export From DragonBones version 2.0" elseif ArmatureTestIndex.TEST_PERFORMANCE == idx then return "Test Performance" - elseif ArmatureTestIndex.TEST_PERFORMANCE_BATCHNODE == idx then - return "Test Performance of using BatchNode" elseif ArmatureTestIndex.TEST_CHANGE_ZORDER == idx then return "Test Change ZOrder Of Different Armature" elseif ArmatureTestIndex.TEST_ANIMATION_EVENT == idx then @@ -106,8 +103,6 @@ function ArmatureTestLayer.subTitle(idx) return "current percent :" elseif ArmatureTestIndex.TEST_PERFORMANCE == idx then return "Current Armature Count : " - elseif ArmatureTestIndex.TEST_PERFORMANCE_BATCHNODE == idx then - return "Current Armature Count : " elseif ArmatureTestIndex.TEST_PARTICLE_DISPLAY == idx then return "Touch to change animation" elseif ArmatureTestIndex.TEST_USE_DIFFERENT_PICTURE == idx then @@ -125,7 +120,12 @@ function ArmatureTestLayer.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) layer:creatTitleAndSubTitle(armatureSceneIdx) end @@ -174,7 +174,7 @@ function ArmatureTestLayer:createMenu() end function ArmatureTestLayer.toExtensionMenu() - ccs.ArmatureDataManager:destoryInstance() + ccs.ArmatureDataManager:destroyInstance() local scene = CocoStudioTestMain() if scene ~= nil then cc.Director:getInstance():replaceScene(scene) @@ -278,7 +278,12 @@ function TestAsynchronousLoading.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer @@ -301,7 +306,7 @@ function TestDirectLoading:onEnter() ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("armature/bear.ExportJson") ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("armature/bear.ExportJson") local armature = ccs.Armature:create("bear") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setPosition(cc.p(VisibleRect:center())) self:addChild(armature) end @@ -311,7 +316,13 @@ function TestDirectLoading.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) + layer:creatTitleAndSubTitle(armatureSceneIdx) end return layer @@ -333,7 +344,7 @@ end function TestCSWithSkeleton:onEnter() local armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setScale(0.2) armature:setAnchorPoint(cc.p(0.5, 0.5)) armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2)) @@ -346,7 +357,12 @@ function TestCSWithSkeleton.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) layer:creatTitleAndSubTitle(armatureSceneIdx) end @@ -368,7 +384,7 @@ end function TestDragonBones20:onEnter() local armature = ccs.Armature:create("Dragon") - armature:getAnimation():playByIndex(1) + armature:getAnimation():playWithIndex(1) armature:getAnimation():setSpeedScale(0.4) armature:setPosition(cc.p(VisibleRect:center().x, VisibleRect:center().y * 0.3)) armature:setScale(0.6) @@ -381,7 +397,12 @@ function TestDragonBones20.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) layer:creatTitleAndSubTitle(armatureSceneIdx) end return layer @@ -423,7 +444,7 @@ function TestPerformance:addArmature(num) for i = 1, num do self._armatureCount = self._armatureCount + 1 local armature = ccs.Armature:create("Knight_f/Knight") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setPosition(50 + self._armatureCount * 2, 150) armature:setScale(0.6) self:addArmatureToParent(armature) @@ -480,7 +501,12 @@ function TestPerformance.create() layer:createMenu() layer:createToExtensionMenu() layer:creatTitleAndSubTitle(armatureSceneIdx) - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer end @@ -557,7 +583,12 @@ function TestPerformanceBatchNode.create() layer:createMenu() layer:createToExtensionMenu() layer:creatTitleAndSubTitle(armatureSceneIdx) - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer end @@ -580,21 +611,21 @@ function TestChangeZorder:onEnter() self.currentTag = -1 local armature = ccs.Armature:create("Knight_f/Knight") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100 )) armature:setScale(0.6) self.currentTag = self.currentTag + 1 self:addChild(armature, self.currentTag, self.currentTag) armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setScale(0.24) armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100)) self.currentTag = self.currentTag + 1 self:addChild(armature, self.currentTag, self.currentTag) armature = ccs.Armature:create("Dragon") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setPosition(cc.p(winSize.width / 2, winSize.height / 2 - 100)) armature:setScale(0.6) self.currentTag = self.currentTag + 1 @@ -615,8 +646,13 @@ function TestChangeZorder.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer end @@ -654,7 +690,7 @@ function TestAnimationEvent:onEnter() local function animationEvent(armatureBack,movementType,movementID) local id = movementID - if movementType == ccs.MovementEventType.LOOP_COMPLETE then + if movementType == ccs.MovementEventType.loopComplete then if id == "Fire" then local actionToRight = cc.MoveTo:create(2, cc.p(VisibleRect:right().x - 50, VisibleRect:right().y)) armatureBack:stopAllActions() @@ -680,8 +716,13 @@ function TestAnimationEvent.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer end @@ -700,27 +741,32 @@ function TestFrameEvent.extend(target) end function TestFrameEvent:onEnter() + + local gridNode = cc.NodeGrid:create() + local armature = ccs.Armature:create("HeroAnimation") armature:getAnimation():play("attack") armature:getAnimation():setSpeedScale(0.5) armature:setPosition(cc.p(VisibleRect:center().x - 50, VisibleRect:center().y -100)) local function onFrameEvent( bone,evt,originFrameIndex,currentFrameIndex) - if (not self:getActionByTag(frameEventActionTag)) or (not self:getActionByTag(frameEventActionTag):isDone()) then - self:stopAllActions() + if (not gridNode:getActionByTag(frameEventActionTag)) or (not gridNode:getActionByTag(frameEventActionTag):isDone()) then + gridNode:stopAllActions() + local action = cc.ShatteredTiles3D:create(0.2, cc.size(16,12), 5, false) action:setTag(frameEventActionTag) - self:runAction(action) + gridNode:runAction(action) end end armature:getAnimation():setFrameEventCallFunc(onFrameEvent) + gridNode:addChild(armature) - self:addChild(armature) + self:addChild(gridNode) local function checkAction(dt) - if self:getNumberOfRunningActions() == 0 and self:getGrid() ~= nil then - self:setGrid(nil) + if gridNode:getNumberOfRunningActions() == 0 and gridNode:getGrid() ~= nil then + gridNode:setGrid(nil) end end @@ -740,7 +786,12 @@ function TestFrameEvent.create() layer:createMenu() layer:createToExtensionMenu() layer:creatTitleAndSubTitle(armatureSceneIdx) - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer end @@ -765,7 +816,7 @@ function TestParticleDisplay:onEnter() self.animationID = 0 self.armature = ccs.Armature:create("robot") - self.armature:getAnimation():playByIndex(0) + self.armature:getAnimation():playWithIndex(0) self.armature:setPosition(VisibleRect:center()) self.armature:setScale(0.48) self:addChild(self.armature) @@ -775,7 +826,7 @@ function TestParticleDisplay:onEnter() local bone = ccs.Bone:create("p1") bone:addDisplay(p1, 0) - bone:changeDisplayByIndex(0, true) + bone:changeDisplayWithIndex(0, true) bone:setIgnoreMovementBoneData(true) bone:setZOrder(100) bone:setScale(1.2) @@ -783,7 +834,7 @@ function TestParticleDisplay:onEnter() bone = ccs.Bone:create("p2") bone:addDisplay(p2, 0) - bone:changeDisplayByIndex(0, true) + bone:changeDisplayWithIndex(0, true) bone:setIgnoreMovementBoneData(true) bone:setZOrder(100) bone:setScale(1.2) @@ -791,7 +842,7 @@ function TestParticleDisplay:onEnter() local function onTouchBegan(x, y) self.animationID = (self.animationID + 1) % self.armature:getAnimation():getMovementCount() - self.armature:getAnimation():playByIndex(self.animationID) + self.armature:getAnimation():playWithIndex(self.animationID) return false end @@ -810,8 +861,13 @@ function TestParticleDisplay.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer @@ -837,7 +893,7 @@ function TestUseMutiplePicture:onEnter() self.displayIndex = 1 self.armature = ccs.Armature:create("Knight_f/Knight") - self.armature:getAnimation():playByIndex(0) + self.armature:getAnimation():playWithIndex(0) self.armature:setPosition(cc.p(VisibleRect:left().x + 70, VisibleRect:left().y)) self.armature:setScale(1.2) self:addChild(self.armature) @@ -861,7 +917,7 @@ function TestUseMutiplePicture:onEnter() local function onTouchBegan(x, y) self.displayIndex = (self.displayIndex + 1) % (table.getn(weapon) - 1) - self.armature:getBone("weapon"):changeDisplayByIndex(self.displayIndex, true) + self.armature:getBone("weapon"):changeDisplayWithIndex(self.displayIndex, true) return false end @@ -880,8 +936,13 @@ function TestUseMutiplePicture.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer @@ -904,7 +965,7 @@ function TestAnchorPoint:onEnter() local i = 1 for i = 1 , 5 do local armature = ccs.Armature:create("Cowboy") - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setPosition(VisibleRect:center()) armature:setScale(0.2) self:addChild(armature, 0, i - 1) @@ -923,8 +984,13 @@ function TestAnchorPoint.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer @@ -950,7 +1016,7 @@ function TestArmatureNesting:onEnter() self.weaponIndex = 0 self.armature = ccs.Armature:create("cyborg") - self.armature:getAnimation():playByIndex(1) + self.armature:getAnimation():playWithIndex(1) self.armature:setPosition(VisibleRect:center()) self.armature:setScale(1.2) self.armature:getAnimation():setSpeedScale(0.4) @@ -958,8 +1024,8 @@ function TestArmatureNesting:onEnter() local function onTouchBegan(x, y) self.weaponIndex = (self.weaponIndex + 1) % 4 - self.armature:getBone("armInside"):getChildArmature():getAnimation():playByIndex(self.weaponIndex) - self.armature:getBone("armOutside"):getChildArmature():getAnimation():playByIndex(self.weaponIndex) + self.armature:getBone("armInside"):getChildArmature():getAnimation():playWithIndex(self.weaponIndex) + self.armature:getBone("armOutside"):getChildArmature():getAnimation():playWithIndex(self.weaponIndex) return false end @@ -978,8 +1044,13 @@ function TestArmatureNesting.create() if nil ~= layer then layer:createMenu() layer:createToExtensionMenu() - layer:onEnter() layer:creatTitleAndSubTitle(armatureSceneIdx) + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer @@ -1005,7 +1076,7 @@ function Hero:changeMount(armature) --note self:retain() - self:playByIndex(0) + self:playWithIndex(0) self._mount:getBone("hero"):removeDisplay(0) self._mount:stopAllActions() self:setPosition(self._mount:getPosition()) @@ -1015,22 +1086,22 @@ function Hero:changeMount(armature) else self._mount = armature self:retain() - self:removeFromParentAndCleanup(false) + self:removeFromParent(false) local bone = armature:getBone("hero") bone:addDisplay(self, 0) - bone:changeDisplayByIndex(0, true) + bone:changeDisplayWithIndex(0, true) bone:setIgnoreMovementBoneData(true) self:setPosition(cc.p(0,0)) - self:playByIndex(1) + self:playWithIndex(1) self:setScale(1) self:release() end end -function Hero:playByIndex(index) - self:getAnimation():playByIndex(index) +function Hero:playWithIndex(index) + self:getAnimation():playWithIndex(index) if nil ~= self._mount then - self._mount:getAnimation():playByIndex(index) + self._mount:getAnimation():playWithIndex(index) end end @@ -1112,7 +1183,7 @@ function TestArmatureNesting2:onEnter() self._hero = Hero.create("hero") self._hero._layer = self - self._hero:playByIndex(0) + self._hero:playWithIndex(0) self._hero:setPosition(cc.p(VisibleRect:left().x + 20, VisibleRect:left().y)) self:addChild(self._hero) @@ -1126,7 +1197,7 @@ end function TestArmatureNesting2:createMount(name,pt) local armature = ccs.Armature:create(name) - armature:getAnimation():playByIndex(0) + armature:getAnimation():playWithIndex(0) armature:setPosition(pt) self:addChild(armature) return armature @@ -1139,7 +1210,12 @@ function TestArmatureNesting2.create() layer:createMenu() layer:createToExtensionMenu() layer:creatTitleAndSubTitle(armatureSceneIdx) - layer:onEnter() + local function onNodeEvent(event) + if "enter" == event then + layer:onEnter() + end + end + layer:registerScriptHandler(onNodeEvent) end return layer @@ -1153,7 +1229,7 @@ local armatureSceneArr = TestCSWithSkeleton.create, TestDragonBones20.create, TestPerformance.create, - TestPerformanceBatchNode.create, + --TestPerformanceBatchNode.create, TestChangeZorder.create, TestAnimationEvent.create, TestFrameEvent.create,