cocostudio中帧事件重复两遍的问题

描述:
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");
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值