PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Rotated sprite question

I'm coding a game where I need to blit a time arrow, that is, an arrow sprite that is rotated to display a little clock.

For it to work, the center of the rotation needs to be the bottom edge of the arrow, but I can't get it to work... could anyone give me some help on this simple problem?

Here is the sprite I'm using so you can get a better view of the question:

Image

I've tried looking at the GapiDraw docs but I doesn't give much information on that...
Since rotation is easiest if you rotate about the center, make your clock hand sprite twice the current length, with the new half a transparent color. Now the sprite will rotate about the center, and only the non-transparent portion will be visible.
That's what I'm currently doing.
I just thought there may be some better way to do it...
One method that might work is if you rotate it in the middle and then offset the sprite. The offset is a simple trigonometric formula. Probably something like dx = cos(a)*arrow_length/2, dy = sin(a)*arrow_length/2

/Okku