how to get rotation of the object

16 views
Skip to first unread message

Tobiasz Palka

unread,
Jul 24, 2013, 7:51:12 AM7/24/13
to gam...@googlegroups.com
Hi, is there a way to get current rotation of an element? I can change it using gamejs.transform.rotate() but I can't ask for it's rotation (degrees, radians, whatever..). I'm pretty sure I can do it by myself checking topleft and topright attributes, or even setting rotation property of the object, change it and then update the object rotation using mentioned method, but this is not the way I wan't to go.

Thanks in advance ;)
Cheers.

si...@nekapuzer.at

unread,
Jul 24, 2013, 7:59:57 AM7/24/13
to gam...@googlegroups.com
> Hi, is there a way to get current rotation of an element? I can change it
> using *gamejs.transform.rotate()* but I can't ask for it's rotation
> (degrees, radians, whatever..).

no, you didn't miss it, this doesn't exist :)

Beware that if you keep rotating the very same image again & again it will
lose quality. Generally, it's better to store the desired rotation (as you
plan on doing) and apply that rotation to the original image just before
you display it (or if you want to optimize that: create the rotated image
from the original image whenever rotation changes)

hope that helps...
simon

si...@nekapuzer.at

unread,
Jul 26, 2013, 6:09:22 AM7/26/13
to gam...@googlegroups.com
hi tobiasz,
i'm not sure what you mean.

if you rotate the image, it's going to get a bit bigger (unless it's
quadratic and you rotate in 90degree steps) - maybe this is the effect you
are seeing?

simon

> Ok I just figured it out.. Thanks!
>
> There is another problem. While rotating (without creating a rect with
> scale, because this changes scale of the image) the image is moved a bit
> to
> the bottom-right, just like the corners could not pass the left and top
> borders of the rect. I have no idea why this happens...
>
> HTML5 surface has translate method to move the origin. Is there a way to
> do
> this with gamejs.image? Maybe this can solve my problem..
>
>
>

Reply all
Reply to author
Forward
0 new messages