描述:
cocos2dx 2.2.3版本,在cocostudio中设置的帧事件在勾选循环play之后,会执行两遍帧事件
原因分析:
我打了log发现如下:
skill_duangang 90 originFrameIndex 49 currentFrameIndex49 duangangBlackScreen
解决办法:
在帧事件回调函数里添加代码如下:
if (armature->getAnimation()->m_pMovementData->duration-1 == currentFrameIndex)
{
CCLOG("frame event is not at the last frame");
return;
}
如下为帧事件函数声明:
/*
* originFrameIndex is the frame index editted in Action Editor
* currentFrameIndex is the current index animation played to
* frame event may be delay emit, so originFrameIndex may be different from currentFrameIndex.
*/
void onFrameEvent(CCBone *bone, const char *evt, int originFrameIndex, int currentFrameIndex)
{
CCLog("hero frame event");
}
cocos2dx 2.2.3版本,在cocostudio中设置的帧事件在勾选循环play之后,会执行两遍帧事件
原因分析:
我打了log发现如下:
skill_duangang 90 originFrameIndex 49 currentFrameIndex49 duangangBlackScreen
skill_duangang 90 originFrameIndex 49 currentFrameIndex 89 duangangBlackScreen
【说明:skill_duangang:动作名 90:总帧数 originFrameIndex:编辑器设置帧事件坐在的帧数 currentFrameIndex:动画实际播放的帧数duangangBlackScreen:帧事件名】
发现当播放到currentFrameIndex最后一帧后又会重走一遍当前动画的所有帧事件解决办法:
在帧事件回调函数里添加代码如下:
if (armature->getAnimation()->m_pMovementData->duration-1 == currentFrameIndex)
{
CCLOG("frame event is not at the last frame");
return;
}
如下为帧事件函数声明:
/*
* originFrameIndex is the frame index editted in Action Editor
* currentFrameIndex is the current index animation played to
* frame event may be delay emit, so originFrameIndex may be different from currentFrameIndex.
*/
void onFrameEvent(CCBone *bone, const char *evt, int originFrameIndex, int currentFrameIndex)
{
CCLog("hero frame event");
}