1、添加动画缓存

//添加动画缓存
		cc.spriteFrameCache.addSpriteFrames(res.bug_plist);
		this.spriteSheet = new cc.SpriteBatchNode(res.bug_png);
		this.addChild(this.spriteSheet);

 2、初始化动作(参数1表示运行每一帧的时间间隔)

//初始化动作
		var animFrames = [];
		for (var i = 1; i <= 2; i++) {
			var str = "hero" + i + ".png";
			var frame = cc.spriteFrameCache.getSpriteFrame(str);
			animFrames.push(frame);
		}
		animation = new cc.Animation(animFrames, 1);
		this.runningAction = new cc.Animate(animation);
		this.runningAction.retain();

 3、运行动作

sprite1.runAction(cc.RepeatForever(this.runningAction));

 

相关文章:

  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-28
  • 2021-05-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2021-10-16
相关资源
相似解决方案