Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

How to change sprites in Flaying dog when the object collide


Javier
 Share

Recommended Posts

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.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...