cocos3 帧动画无限重复

使用autoaction和repeat实现动画循环播放
本文详细介绍了如何在代码中使用autoaction和repeat函数实现动画的循环播放,并通过设置帧延迟来控制动画播放速度。具体步骤包括创建动画、加载图片帧、设置帧间隔时间和循环播放属性。
    auto animation = Animation::create(); 
    animation->addSpriteFrameWithFile("NPC/hero.png");
    animation->addSpriteFrameWithFile("NPC/hero1.png");
  
    // should last 2.8 seconds. And there are 14 frames. 
    animation->setDelayPerUnit(2.8f / 14.0f); 
    animation->setRestoreOriginalFrame(true); 
    auto action = Animate::create(animation);
    auto repeat=RepeatForever::create(action);
    auto creep=RepeatForever::create(action);
    runAction(creep); 

 

转载于:https://www.cnblogs.com/yufenghou/p/4189593.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值