创建动画
init:function(){ this._super(); //create sprite sheet cc.spriteFrameCache.addSpriteFrames(res.running_plist); this.spriteSheet = new cc.SpriteBatchNode(res.runner_png); this.addChild(this.spriteSheet); //init runningAction var animFrames = []; for(var i=0;i<8;i++){ var str = "runner" + i + ".png"; var frame = cc.spriteFrameCache.getSpriteFrame(str); animFrames.push(frame); } var animation = new cc.Animation(animFrames,0.1); this.runningAction = new cc.RepeatForever(new cc.Animate(animation)); //create the hero sprite this.sprite = new cc.Sprite("#runner0.png"); this.sprite.attr({x:80,y:85}); this.sprite.runAction(this.runningAction); this.addChild(this.sprite); //create the move action //var actionTo = new cc.MoveTo(2,cc.p(300,85)); //spriteRunner.runAction(actionTo); //this.addChild(spriteRunner); }