Jump to content

Sprite Chasing Sprite


MikeW
 Share

Recommended Posts

I am writing a game where when a target is hit it drops a coin (creates new sprite) 

I want to have that sprite move towards the player 

 var targetAngle = this.game.math.angleBetween( coins.y, coins.x, car.body.y, car.body.x   );

        coins.rotation=targetAngle;
                    coins.body.thrust(400);

 

They always head straight down , can someone help me please. Having trouble finding a sprite chasing target example. 

 

Link to comment
Share on other sites

I believe there's a 'moveTo' or 'moveToward' method lying around somewhere, probably on the Phaser.Sprite class. I'm on my phone now so I can really search for it in the docs, but when you find it, you can probable call that in the update method for your sprite so it gets called every game loop

Link to comment
Share on other sites

Probably at one point I had thrust almost working - and had it orbiting the final target. 

Thanks - if I have to I will use update and do the math myself should never be more then 3-4 in existance to managing the little stuff should not be that critical

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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