I have got a sprite that moves based on touch location. I am using box2d for collision and when the sprite collides with another object i rotate the sprite 180 degree to face away from the collision and my aim is to move the sprite that collided x amount of pixels in the direction of rotation basically giving a bounce off affect.
Can anyone tell me how i can get a position which is x amount of pixels in front of the sprite based on the rotation.
Thanks
You can get the direction your sprite is facing with the following formula:
The vector it returns will be pointing exactly towards the spot you are trying to calculate. Normalize it, then multiply it by the number of pixels you want to reach out to. That should do the trick.
The above is C# code, but you should be able to convert it to your language.