我是 Cocos2d 的新手,我对Cocos2d-HTML5中的动画有疑问。
下面是我的精灵的构造函数。我已经用TexturePackerplist
生成了文件。我想播放动画并无限重复。我可以通过以下方式创建动画来播放一次:
var animation = new cc.Animation(frames, 0.2);
但是当我将循环计数作为第三个参数传递时,我得到了错误Uncaught TypeError: Object #<Class> has no method 'getDelayUnits'
ctor: function (position) {
this._super();
var cache = cc.SpriteFrameCache.getInstance();
cache.addSpriteFrames(s_dogList, s_Dog);
var frames = [];
for (var i = 1; i <= this.NUMBER_OF_FRAMES; i++) {
var spriteFrame = cache.getSpriteFrame('dog' + i + '.png');
frames.push(spriteFrame);
};
this.initWithSpriteFrame(frames[0]);
var animation = cc.Animation.create(frames, 0.2, 100);
var animate = cc.Animate.create(animation);
this.runAction(animate);
}
我研究了代码,发现在使用 3 个参数(带loops
参数)创建动画时,它需要每个帧都是AnimationFrame
类的实例。但是当我只传递 2 个参数时,框架必须是SpriteFrame
类的实例。如何创建动画AnimationFrame
并无限重复?