Jump to content

Hit by a draggable sprite.


cap
 Share

Recommended Posts

Let's say there are two sprites and one of them is draggable. How to implement "impact" when the draggable  sprite hits the second one, such that the second sprites starts moving with the speed of the draggable one. Here is what I tried:

create() {    this.cat = this.game.add.sprite(...);    this.cat.body.bounce.setTo(0.5, 0.5);    this.cat.input.enableDrag(false, true, false, 255);    this.dog = this.game.add.sprite(....);    this.dog.body.bounce.setTo(0.5, 0.5);}
update() {
    game.physics.collide(this.cat, this.dog);
}

It seems this code does  nothing. Could you help please?

Link to comment
Share on other sites

Hello,

The behaviour you're encountering is intended, at the moment and as of Phaser 1.1.3, collision against a draggable sprite is impossible.

 

You have two choices, implement the collision yourself, or wait for 1.1.4 to be released, with the brand-new physics system that Richard implemented, it will be possible, you can check it out in the dev branch, but be careful because it's not entirely ready yet.

Link to comment
Share on other sites

Thanks a lot for your help!!! 

Still doesn't work... That's my code:

 create() {        this.input.maxPointers = 1;        this.stage.disableVisibilityChange = true;        this.cat = this.game.add.sprite(50, 50, 'cat');        this.cat.anchor.setTo(0.5, 0.5);        this.cat.body.bounce.setTo(0.5, 0.5);                this.cat.inputEnabled = true;        this.cat.input.enableDrag(false, true, false, 255);        this.cat.inputEnabled = true;        this.dog = this.game.add.sprite(200, 200, 'dog');        this.dog.anchor.setTo(0.5, 0.5);        this.dog.body.velocity.x = this.dog.body.velocity.y = 1;         this.dog.body.bounce.setTo(0.5, 0.5);                this.dog.inputEnabled = true;    }    update() {        this.game.physics.collide(this.cat, this.dog);    }
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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