quick lua 使用spine骨骼动画

看下下面两个文件

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

 

quick 3.3 "异步"加载Spine方案:http://blog.csdn.net/chenhaobright/article/details/44619633

http://blog.csdn.net/chenhaobright/article/details/44258399

转载于:https://www.cnblogs.com/zhangfeitao/p/4531018.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值