Yaro
Yaro

Reputation: 75

Sprite Rotation around a point Andengine/Java

Does anyone know how can I get a sprite/bitmap to rotate by a certain angle where the point on one the sides will always remain in the same position.

enter image description here

I have a blue line in the image and I need one of the sides to remain in the same position at all times. It would be great help if somebody could tell me how to do this. Im trying to do this in Andengine/Java. So a solution in either would be most helpful.

Thanks

Regards, Yaro

Upvotes: 4

Views: 2154

Answers (3)

macgyver
macgyver

Reputation: 1

I just find out a solution for rotate a sprite at any center point. First you create a virtual entity and attach your sprite into this entity (notice: position of sprite is relative with your entity), then you move rotation center of the sprite (default at center of image) to overlap the rotation center of the entity. Final, you set rotation for the entity instead of the sprite. Hope this helpful ^^

Upvotes: 0

Alexey Barabanov
Alexey Barabanov

Reputation: 21

The AndEngine has a good method called setRotationCenter. :) By default rotation center set to center of sprite (half of width, half of height). You can easily change this point.

Upvotes: 2

Kirill Kulakov
Kirill Kulakov

Reputation: 10245

The AndEngine is quite limited with regard to rotation and positioning, I've faced a similar problem on my own, and the only way to solve it was overriding methods and extending classes.

I'd recommend you to implantation the a new method which will set the rotation axis, and override the setRotation() method, to use this axis, I guess you could figure out how to rotate the sprite on a different axis by changing its position which changing its rotation

Upvotes: 0

Related Questions