CocoStudio Lualua动画调用 导出的基本动画播放

如果当前没有动画,用

local HeroHand = cc.csloader:createNode( “Hero.csb” );

创建出动画,再给它加上ActionTimeline。

local HeroTimeline = cc.csloader:createTimeline( “Hero.csb” );

调用 runAction 函数

HeroHand:runAction( HeroTimeline);

将创建出来的 Hand 添加显示层级

Layer:addChild( HeroHand);

可以给动画设置帧事件的回调

HeroTimeline:setFrameEventCallFunc( function( event )

local eventName = event:getEvent();

--eventName 得到的就是在编辑器里设置的帧事件字符串

print( "eventName = " .. tostring( eventName) );

end);

在lua里面没法设置结束回调。。。但是你可以在结束的那一帧设置一个帧事件 字符串 你随便,用上面的函数判断下你设置的最后一帧的字符串,就知道是不是最后一帧了。

调用播放动画也很简单:

C++里面有很多的播放函数

/** Goto the specified frame index,and start playing from this index.
* @param startIndex The animation will play from this index.
*/
virtual void gotoFrameAndplay(int startIndex);


/** Goto the specified frame index,and start playing from this index.
* @param startIndex The animation will play from this index.
* @param loop Whether or not the animation need loop.
*/
virtual void gotoFrameAndplay(int startIndex,bool loop);


/** Goto the specified frame index,and start playing from start index,end at end index.
* @param startIndex The animation will play from this index.
* @param endindex The animation will end at this index.
* @param loop Whether or not the animation need loop.
*/
virtual void gotoFrameAndplay(int startIndex,int endindex,end at end index.
* @param startIndex The animation will play from this index.
* @param endindex The animation will end at this index.
* @param currentFrameIndex set current frame index.
* @param loop Whether or not the animation need loop.
*/
virtual void gotoFrameAndplay(int startIndex,int currentFrameIndex,bool loop);

上面的都是通过帧播放,

virtual void play(std::string animationName,bool loop);

这个函数是通过名字播放

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...