Jump to content

How to change sprites in Flaying dog when the object collide


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

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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