Jump to content

collision callback not working on an enemy if the player is stable


MisterMaSK
 Share

Recommended Posts

so i am creating a player sprite and an enemy sprite

and then i am adding a tween to the enemy like this - 

this.add.tween(this.enemy).to({ x: 300 }, 2000, Phaser.Easing.Quadratic.InOut, true, 0, 1000, true);

then i add a collision callback - 

this.physics.collide(this.enemy, this.player, this.player_die, null, this);

the player_die function simply kills the player sprite.

 

 

but when i test it, 

if the player simply goes in between the path of the tween and stays still, the player_die function is not called.

the enemy just goes through the player and nothing happens.

but if the player is moving while coming in contact with the enemy, then the player_die function is called

 

can i make the check work everytime and not just when the player is moving?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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