是继承ccs.ProcessBase的,那么在lua这边,ArmatureAnimation的实例如何调用他父类ProcessBase的方法?
我现在就是想通过armature获取animation然后通过animation获取当前播放动画到第几帧。然后看api发现ccs.ArmatureAnimation 是继承ccs.ProcessBase的,然后在ccs.ProcessBase中有http://cn.cocos2d-x.org/doc/cocos2d-x-3.0/dd/daf/classcocostudio_1_1_process_base.html#ade2c7c284c2fb31c5b6144f4cf48f603 ()这个方法,然后现在问题就是在lua这边不知道如何通过animation调用他父类的这个方法?
问题解决了,我在lua_cocos2dx_studio_auto.cpp 自己把这个接口导出来了就好了
步骤: tolua_function(tolua_S,“getCurrentFrameIndex”,lua_cocos2dx_studio_ArmatureAnimation_getCurrentFrameIndex);添加在注册接口里面
然后这段代码添加上
int lua_cocos2dx_studio_ArmatureAnimation_getCurrentFrameIndex(lua_State* tolua_S)
{
int argc = 0;
cocostudio::ArmatureAnimation* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S, 1, “ccs.ArmatureAnimation”, 0, &tolua_err)) goto tolua_lerror;
#endif
cobj = (cocostudio::ArmatureAnimation*)tolua_tousertype(tolua_S, 1, 0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S, “invalid ‘cobj’ in function ‘lua_cocos2dx_studio_ArmatureAnimation_getCurrentFrameIndex’”, nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if (!ok)
return 0;
int ret = cobj->getCurrentFrameIndex();
tolua_pushnumber(tolua_S, (lua_Number)ret);
return 1;
}
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getCurrentFrameIndex", argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S, “#ferror in function ‘lua_cocos2dx_studio_ArmatureAnimation_getCurrentFrameIndex’.”, &tolua_err);
#endif
return 0;
}
重新编译就,就可以直接animation:getCurrentFrameIndex()获取当前动画的当前帧了
mark…
mark…
mark。。。。