Reputation: 275
I'm trying to get a spite to follow another sprites path exactly.
The first sprite is controlled via a virtual joystick and the second sprite should follow the first just behind, just like a snake game but more than 4 directions.
what is the best way to go about this?
Or how do i log the first sprites path and then get others to follow this?
Upvotes: 0
Views: 284
Reputation: 4171
You don't provide any code to go with your question... You should try to post something, to see how we can do things with what you've got. Anyways...
You should store the first sprite's X and Y position values, many of them in a set of time (a buffer, if you will). Register the sprite's XY positions in an array, where the older positions get deleted and the new positions take their place.
Then assign those positions to the second sprite, with a delay.
Edit:
I'm guessing the x and y positions of the first sprite are the
self.player.position.x, self.player.position.y
so you would store these at regular time intervals in an array, and delete the older positions as you assign them to the second sprite.
This should be very easy to do, provided that you understand the code that you're using.
Upvotes: 1