创建动画
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); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。