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

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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