看下下面两个文件
<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.换装(需要去学习)
(1)全部换装SetSkin
(2)局部换装
时间: 2024-10-19 08:40:42