Hi I have an object that should change directions
from clockwise to anticlockwise and viceversa on button left or right arrow down.
For that I wrote two events for button downs.
and for anticlock wise, I just replaced sin by cos and cos by sin.
Now when changing directions the object is not starting from where it stopped. It is disappering from there and generating at a random point on the circumference. Can someone help me with this.?
every object already has an angle attribute. you could just, on every tick, set angle to object.angle + speed * dt to go clockwise, or object.angle - speed * dt to go anticlockwise. The angle will stay where it is when you change directions.
Develop games in your browser. Powerful, performant & highly capable.
AllanR Thanks for your solution. I combined it with another one and got what I want. Its very helpful.