Repeat这个Action的本意是可以方便地对某一个动画执行指定的次数,比如这段代码:
scene.index = 0 local delayAction = cc.DelayTime:create(0.5) local callFuncAction1 = cc.CallFunc:create(function() scene.index = scene.index + 1 cclog("index: %d",scene.index) end) local sequenceAction = cc.Sequence:create(delayAction,callFuncAction1) local repeatAction = cc.Repeat:create(sequenceAction,2) scene.action1 = scene:runAction(repeatAction)
它的执行结果是:
cocos2d: [LUA-print] index: 1 cocos2d: [LUA-print] index: 2
执行了两次,不错。尝试将次数从2改为3:
local repeatAction = cc.Repeat:create(sequenceAction,3)
执行结果是:
cocos2d: [LUA-print] index: 1 cocos2d: [LUA-print] index: 2 cocos2d: [LUA-print] index: 3
嗯,3次,不错。现在,见证奇迹的时刻到了,把delayAction的0.5秒改为0.1秒,保持次数依然为3次不变:
local delayAction = cc.DelayTime:create(0.5) ... local repeatAction = cc.Repeat:create(sequenceAction,3)
再次执行,结果居然是执行了4次!!
cocos2d: [LUA-print] index: 1 cocos2d: [LUA-print] index: 2 cocos2d: [LUA-print] index: 3 cocos2d: [LUA-print] index: 4
研究许久,无任何结论,巨坑一个,甚至有些情况下在CallFunc内去stopAction都不起作用,简单来说,就是珍爱生命,远离Repeat这个神经病。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。