Jump to content

Collision Arcade Physics Player vs Baddies


lenlac
 Share

Recommended Posts

Ok so i am exploring another option so far I got

function collideEnemy (player, baddie) {    if( baddie.touching.up )    {        //Call a jump function or something here...        player.body.velocity.y = -200;        //Maybe put the enemy into a different group so it doesn't collide with the player anymore...        baddie.kill();    }    else     {        //You would probably want something a little more than this...        player.kill();    }}

which i found in the forum.

 

however the part:

 

if( baddie.touching.up ) is freezing the game. 

 

i am sure its syntax somehow. Could anyone help with the proper way to call this function with Phaser 2.2?

 

for fun I tested

 

if( 1 < 2 ) and tested to see if it would work and it does. 

 

Could anyone else help with this? thanks.

Link to comment
Share on other sites

well i found this solution and implemented it.

player.body.y + player.body.height < enemie.body.y + 20

I would still like to be able to use the phaser api touching.up if anyone has any advice.

 

ty

 

the update function changed to :

 

game.physics.arcade.overlap(player, baddie);

 

EDIT # 3

 

OH LORD after hours of stupidity. The baddie.body.touching.up as an If statement works when when you use the overlap instead of collide!

 

i am exhausted.lol

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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