I want that an object follows a path, in Peggle game there are some pegs that have movement in a closed path. How can i get the same result? I guess that I can use parametric curve but I need use the velocity and not the position (x, y).
I use NAPE and I have this in my gameloop:
//circunference
angle = angle + 1*(Math.PI / 180);
movableBall.position.x = radius * Math.cos(angle)+ h;
movableBall.position.y = radius * Math.sin(angle)+ k;
It works but I can not control the velocity, each movableBall
must have its own velocity.
Besides, from docs of NAPE:
"Setting the position of a body is equivalent to simply teleporting the body; for instance moving a kinematic body by position is not the way to go about things.."
I want to use:
movableBall.velocity.x =??
movableBall.velocity.y = ??
The final idea is to follow others paths like the Lemniscate of Bernoulli.