Hello guys,
I'm working on a game and I must rotate a bomb around its center point.
I want to rotate the whole animation/skeleton not only one bone...
Right now the bomb seems to rotate around another origin (I'm not sure which one).
When I don't rotate the bomb (0 degree angle) it renders perfectly fine but when I apply a rotation to the root bone it circles around my body.
Here are some examples of the issue ingame:
Loading Image
Loading Image
Loading Image
The circle is the box2d body, I know its a little too big but its not important for the problem I have.
I attached to the post the spine project of the bomb.
Finally here is the code I use to render/rotate the bomb.
@Override
public void render(Batch batch, float parentAlpha) {
state.update(Gdx.graphics.getDeltaTime()); // Update the animation time.
//The center point of spine (between the 4 quadrants is in the bottom middle of all my animations)
skeleton.setX(entity.getX() + entity.getWidth() / 2);
skeleton.setY(entity.getY());
state.apply(skeleton); // Poses skeleton using current animations. This sets the bone's local SRT.
skeleton.updateWorldTransform(); // Uses the bone's local SRT to set their world SRT.
skeleton.getRootBone().setRotation(entity.getRotation());
renderer.draw((SpriteBatch) batch, skeleton); // Draw the skeleton images.
}
Any help would be greatly appreciated,
Thank you.