cocos2d-js 运行动画

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));
原文地址:https://www.cnblogs.com/recock/p/4256351.html