Jump to content

Newbie -- racing game, detecting when I'm off track


wichiwichi
 Share

Recommended Posts

Hi there,

 

I'm trying to code a racing game and I'm running into the following issue: I want to detect when I'm off track in order to apply some penalty to the player; I just can't do that.

 

So first of all I've got the ground of Tank's example, which is added with the function land = game.add.tileSprite(0, 0, 800, 600, 'earth');

Then I've got the track, which is a group track = game.add.group(); track.create(0, 0, 'tl90'); and so on...

And finally I've got the car, car = game.add.sprite(0, 0, 'car'); car.anchor.setTo(0.5, 0.5);

 

In the update function I tried game.physics.collide(car, track, collisionHandler, null, this); but with that line track and car collide, so I'm thinking it's not collide what I'm looking for.

 

I tried to make the track immovable with track.body.immovable = true; but it didn't work either.

 

Would someone point me to the function or an example of what I'm looking for?

 

Thank you so much in advance

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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