看下下面兩個文件
<spine/SkeletonRenderer.h>
<spine/SkeletonAnimation.h>
1.lua中創建方法:
sp.SkeletonAnimation:create(‘xxx.json’,'xxx.atlas', 1)
實際上綁定過來的create 是createwithfile,可以參考 lua_cocos2dx_spine_manual.cpp
static void extendCCSkeletonAnimation(lua_State* L) { lua_pushstring(L, "sp.SkeletonAnimation"); lua_rawget(L, LUA_REGISTRYINDEX); if (lua_istable(L,-1)) { tolua_function(L, "create", lua_cocos2dx_CCSkeletonAnimation_createWithFile); tolua_function(L, "registerSpineEventHandler", tolua_Cocos2d_CCSkeletonAnimation_registerSpineEventHandler00); tolua_function(L, "unregisterSpineEventHandler", tolua_Cocos2d_CCSkeletonAnimation_unregisterSpineEventHandler00); tolua_function(L, "setBlendFunc", tolua_spine_SkeletoneAnimation_setBlendFunc); tolua_function(L, "addAnimation", lua_cocos2dx_spine_SkeletonAnimation_addAnimation); tolua_function(L, "setAnimation", lua_cocos2dx_spine_SkeletonAnimation_setAnimation); tolua_function(L, "replaceImage", lua_cocos2dx_spine_SkeletonAnimation_replaceImage); tolua_function(L, "getCustomBounds", lua_cocos2dx_spine_SkeletonAnimation_getCustomBounds); } lua_pop(L, 1); /*Because sp.SkeletonAnimation:create creat a LuaSkeletonAnimation object,so we need use LuaSkeletonAnimation typename for g_luaType*/ std::string typeName = typeid(LuaSkeletonAnimation).name(); g_luaType[typeName] = "sp.SkeletonAnimation"; g_typeCast["SkeletonAnimation"] = "sp.SkeletonAnimation"; }
2.registerSpineEventHandler注冊事件
SP_ANIMATION_START = 0
SP_ANIMATION_END = 1
SP_ANIMATION_COMPLETE = 2
SP_ANIMATION_EVENT = 3
3.setDebugBonesEnabled(true)
spine在調試模式,可以看到骨頭的長度,骨點的位置
4.setDebugSlotsEnabled(true);設置查看每個骨頭綁定的圖片的大小,會用矩形框顯示出來
5.setMix 讓兩個動作之間更加;流暢。單向的,所以我們要相互設置。最后一個是過渡時間
self.aniNode2:setMix("move","idle",0.2) self.aniNode2:setMix("idle","move",0.2)
6.setTimeScale(0.1)
默認是1.0 ,然后咱們可以設置動畫播放的速度。比如人物的行走,美工做的時候,可以統一按照一個速度走。然后在程序里設置不同的速度。
7.換裝(需要去學習)
(1)全部換裝SetSkin
(2)局部換裝