码迷,mamicode.com
首页 > 其他好文 > 详细

quick lua 使用spine骨骼动画

时间:2015-05-26 17:56:12      阅读:1085      评论:0      收藏:0      [点我收藏+]

标签:

看下下面两个文件

<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)局部换装

quick lua 使用spine骨骼动画

标签:

原文地址:http://www.cnblogs.com/zhangfeitao/p/4531018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!