cocos2dx-js 动画
发布时间:2020-12-14 21:23:16 所属栏目:百科 来源:网络整理
导读:创建动画 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 ani
创建动画
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); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |