diff --git a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp index 48b13a2760..42aa895c33 100644 --- a/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp @@ -32,6 +32,8 @@ #include #endif #include "ui/UIWidget.h" +#include "ActionTimeline/CCActionTimeline.h" +#include "ActionTimeline/CSLoader.h" static int tolua_cocos2d_MenuItemImage_create(lua_State* tolua_S) { @@ -7086,6 +7088,51 @@ static void extendCamera(lua_State* tolua_S) lua_pop(tolua_S, 1); } +int lua_cocos2dx_CSLoader_createTimeline(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.CSLoader",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 1) + { + std::string arg0; + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.CSLoader:createTimeline"); + if(!ok) + return 0; + cocostudio::timeline::ActionTimeline* ret = cocos2d::CSLoader::createTimeline(arg0); + object_to_luaval(tolua_S, "ccs.ActionTimeline",(cocostudio::timeline::ActionTimeline*)ret); + return 1; + } + CCLOG("%s has wrong number of arguments: %d, was expecting %d\n ", "cc.CSLoader:createTimeline",argc, 1); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_CSLoader_createTimeline'.",&tolua_err); +#endif + return 0; +} + +static void extendCSLoader(lua_State* tolua_S) +{ + lua_pushstring(tolua_S, "cc.CSLoader"); + lua_rawget(tolua_S, LUA_REGISTRYINDEX); + if (lua_istable(tolua_S,-1)) + { + tolua_function(tolua_S, "createTimeline", lua_cocos2dx_CSLoader_createTimeline); + } + lua_pop(tolua_S, 1); +} + int register_all_cocos2dx_manual(lua_State* tolua_S) { if (NULL == tolua_S) @@ -7142,7 +7189,7 @@ int register_all_cocos2dx_manual(lua_State* tolua_S) extendTextureCache(tolua_S); extendGLView(tolua_S); extendCamera(tolua_S); - + extendCSLoader(tolua_S); return 0; } diff --git a/tests/lua-tests/src/CocoStudioTest/CocoStudioActionTimelineTest/CocoStudioActionTimelineTest.lua b/tests/lua-tests/src/CocoStudioTest/CocoStudioActionTimelineTest/CocoStudioActionTimelineTest.lua index d2319daf07..bf5e1e3e6b 100644 --- a/tests/lua-tests/src/CocoStudioTest/CocoStudioActionTimelineTest/CocoStudioActionTimelineTest.lua +++ b/tests/lua-tests/src/CocoStudioTest/CocoStudioActionTimelineTest/CocoStudioActionTimelineTest.lua @@ -59,7 +59,7 @@ end function TimelineTestLayer.title(idx) if TimelineTestIndex.TEST_ACTION_TIMELINE == idx then - return "CSArmature Test Bed" + return "Test ActionTimeline" elseif TimelineTestIndex.TEST_CHANGE_PLAY_SECTION == idx then return "Test Change Play Section" elseif TimelineTestIndex.TEST_TIMELINE_FRAME_EVENT == idx then @@ -188,14 +188,14 @@ end function TestActionTimeline:onEnter() cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("armature/Cowboy0.plist", "armature/Cowboy0.png") - local node = ccs.NodeReader:getInstance():createNode("ActionTimeline/boy_1.ExportJson") - local action = ccs.ActionTimelineCache:getInstance():createAction("ActionTimeline/boy_1.ExportJson") + local node = cc.CSLoader:createNode("ActionTimeline/boy_1.csb") + local action = cc.CSLoader:createTimeline("ActionTimeline/boy_1.csb") node:runAction(action) action:gotoFrameAndPlay(0, 60, true) - node:setScale(0.4) - node:setPosition(0, 0) + node:setScale(0.2) + node:setPosition(150, 100) self:addChild(node) end @@ -241,8 +241,8 @@ end function TestChangePlaySection:onEnter() cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("armature/Cowboy0.plist", "armature/Cowboy0.png") - local node = ccs.NodeReader:getInstance():createNode("ActionTimeline/boy_1.ExportJson") - local action = ccs.ActionTimelineCache:getInstance():createAction("ActionTimeline/boy_1.ExportJson") + local node = cc.CSLoader:createNode("ActionTimeline/boy_1.csb") + local action = cc.CSLoader:createTimeline("ActionTimeline/boy_1.csb") node:runAction(action) action:gotoFrameAndPlay(70, action:getDuration(), true) @@ -308,8 +308,8 @@ end function TestTimelineFrameEvent:onEnter() cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("armature/Cowboy0.plist", "armature/Cowboy0.png") - local node = ccs.NodeReader:getInstance():createNode("ActionTimeline/boy_1.ExportJson") - local action = ccs.ActionTimelineCache:getInstance():createAction("ActionTimeline/boy_1.ExportJson") + local node = cc.CSLoader:createNode("ActionTimeline/boy_1.csb") + local action = cc.CSLoader:createTimeline("ActionTimeline/boy_1.csb") node:runAction(action) action:gotoFrameAndPlay(0, 60, true) @@ -377,8 +377,8 @@ function TestTimelinePerformance:onEnter() cc.SpriteFrameCache:getInstance():addSpriteFramesWithFile("armature/Cowboy0.plist", "armature/Cowboy0.png") for i = 1,100 do - local node = ccs.NodeReader:getInstance():createNode("ActionTimeline/boy_1.ExportJson") - local action = ccs.ActionTimelineCache:getInstance():createAction("ActionTimeline/boy_1.ExportJson") + local node = cc.CSLoader:createNode("ActionTimeline/boy_1.csb") + local action = cc.CSLoader:createTimeline("ActionTimeline/boy_1.csb") node:runAction(action) action:gotoFrameAndPlay(70, action:getDuration(), true) diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 54d6013d43..1a6a14f651 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.h % # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device CSLoader +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device CSLoader ClippingRectangleNode # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -147,7 +147,7 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS AmbientLight3D::[*], CSLoader::[nodeFromXML nodeFromProtocolBuffers createTimeline] -rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames getSpriteFrameByName=getSpriteFrame], +rename_functions = SpriteFrameCache::[getSpriteFrameByName=getSpriteFrame], ProgressTimer::[setReverseProgress=setReverseDirection], AnimationCache::[addAnimationsWithFile=addAnimations], LayerGradient::[initWithColor=init],