[RUBY] ROTATING A SPRITE ALONG ITS CENTER AXIS [SOLVED]

Posts

Pages: 1
Hi everyone,

The Sprite class in RPG Maker's RGSS allows the developer to rotate the sprite, in such a manner:

sprite = Sprite.new
sprite.angle = [Desired angle here]

However, this rotation occurs based on the upper-left hand corner of the sprite. I know how to find the center of a sprite's image (sprite.bitmap.width / 2, sprite.bitmap.height / 2), but I don't know how to adjust the sprite's position after it's been rotated, so it appears as if it's rotated about its center.

Are any math wizards present who can point me in the right direction?

Sincerely,
Zack


-------------

The answer was in the .ox and .oy methods. sprite.ox and sprite.oy set the reference point for rotation. By default, they are at 0 and 0, the top-left of the sprite. Setting them to sprite.bitmap.width / 2 and sprite.bitmap.height / 2 finds the center of the sprite and uses that as a reference point for all calculations, including changing the x, y, and so on.
Pages: 1