MikeW Posted April 17, 2017 Report Share Posted April 17, 2017 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. Quote Link to comment Share on other sites More sharing options...
snowbillr Posted April 17, 2017 Report Share Posted April 17, 2017 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 Quote Link to comment Share on other sites More sharing options...
MikeW Posted April 17, 2017 Author Report Share Posted April 17, 2017 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.