I’m trying to rotate a ball represented by a Sprite around the center of the screen. How ever the ball doesn’t follow a completely circular trajectory.
Here is the function which manages the rotation of the ball:
It may have to do with where the origin of the ball is located (typically the upper-left corner of the sprite).
There are a number of solutions.
You can put the ball in a container sprite and offset it so that its centered in the container and rotate the container. Or you can add the offsets (1/2 ball width and 1/2 ball height) directly to your calculations.
If you created the ball using the Graphics API, you also have the option of drawing the shape so that its centered about the origin.
Actually it’s a SVG loaded with a specific library. The solution with the ball offsets it’s not working, now the ball is getting a really weird trajectory…