Javier Posted April 18, 2014 Share Posted April 18, 2014 I am using flaying dog to learn panda. I have made some little changes in the game by my own but i cant figured out how to use diferent sprits when the object crashes and when the object land. Any help? Quote Link to comment Share on other sites More sharing options...
Javier Posted April 19, 2014 Author Share Posted April 19, 2014 collide: function() { if(!game.scene.ended) { game.scene.gameOver(); this.body.velocity.y = -200; //added this.sprite.alpha=0; this.sprite= new game.Sprite('choque'); this.sprite.anchor.x = 0.2; this.sprite.anchor.y = 0.5; game.scene.stage.addChild(this.sprite);//added } this.body.velocity.x = 0; return true; }, update: function() { this.sprite.position.x = this.body.position.x; this.sprite.position.y = this.body.position.y; //added if(this.body.position.y>750){ this.sprite.alpha=0; this.sprite= new game.Sprite('caida'); this.sprite.anchor.x = 0.7; this.sprite.anchor.y = -0.5; this.sprite.position.x = this.body.position.x; this.sprite.position.y = this.body.position.y; game.scene.stage.addChild(this.sprite); }//added },I already did and it works but i am pretty sure there is a better way to do it. Quote Link to comment Share on other sites More sharing options...
maho125 Posted April 19, 2014 Share Posted April 19, 2014 Try thisif(this.body.position.y>750){ this.sprite.setTexture('caida');} Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.