I have a target object that I’m moving around the screen using physics by applying impulses to it to simulate the outside forces affecting it. I have this working pretty well.
Now I’m adding in enemies to make the game more challenging.
Right now I load the movie clip off screen at a fixed X location, then I’m currently setting the Y location to a range of 100 pixels (50 above or below) the target’s current Y position.
And at the moment I’m using transition.to to move the enemy across the screen. The Y is staying fixed as I animate/move the enemy to its off screen position on the other side. i.e. transition.to(enemey, { time=2000, x=display.contentWidth+60} for a left to right moving enemy. Once the transition is over, I remove the enemy and wait to respawn.
What I would like to do is have the enemy transition towards the target. Easy enough, get the targets x and y, but the target will move and the enemy will seem to always be chasing where the target was.
What is the best way to move the enemy and keep it aimed at where the target is? I’m assuming I’m going to have to not use transition.to and instead animate it in my enterFrame game loop.
Thoughts?
[import]uid: 19626 topic_id: 8133 reply_id: 308133[/import]