Rotating a scaled actor

22 views
Skip to first unread message

Arne Brutschy

unread,
May 4, 2013, 1:03:55 PM5/4/13
to caa...@googlegroups.com
Hey,

is it for example possible to rotate an actor that has been scaled to
50% around its center? If yes, how do I do it?

I always have problems wrapping my head around how scaled actors work...

Thanks
Arne

hyperandroid

unread,
May 4, 2013, 1:57:02 PM5/4/13
to caa...@googlegroups.com

thee two ways to rotate an actor.
setRotation(angle) wich centets around the center regardless sapplied scale/translate (your option)
setRotatoonAnchored(angle,normalized_anchorx, normalized_anchory) which rotates an actor on an anchor point. setting .5 for anchor values is the same as the previous method.

hope that helps.
- i

--
You received this message because you are subscribed to the Google Groups "CAAT javascript framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caatjs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Arne Brutschy

unread,
May 4, 2013, 3:23:37 PM5/4/13
to caa...@googlegroups.com
Hey,

thanks for the reply. My problems seems to stem from the fact that I am
calling setScaleAchor(0, 0) on the actor. I do this because I want to
place the upper right corner of the actor always at the same position
(scaled or not).

If I then rotate, the actor rotates around a completely weird center.

Arne

On Sat, 4 May 2013 10:57:02 -0700 hyperandroid <hypera...@gmail.com>
wrote:

hyperandroid

unread,
May 4, 2013, 3:41:30 PM5/4/13
to caa...@googlegroups.com

you can set different anchors for rotation scale and translate transformations.
i dont get what you mean. if you rotate the uppet right corner will never be in the same position.
the effect you are seeing is this one:

first you rotate an actor by its center.
then, whenevet the top left corner (anchor 0,0) is the actor will svale from that point.
if it os not rotating the actor will scale as pinpointed from the upper left corner. if you rotate 45degs will be scaling downwards etc.

- i

Arne Brutschy

unread,
May 4, 2013, 4:47:04 PM5/4/13
to caa...@googlegroups.com, hypera...@gmail.com

I managed to understand my problem better, it appears when I add
children to an actor container.

Let's assume that I have an actor container and I want to place an
actor inside this container. I scale the actor such that it has the
same size as the container and that it overlays the container perfectly:

var c = new CAAT.Foundation.ActorContainer().
setSize(160, 160).
setPosition(200, 200).
setFillStyle('#000000');
scene.addChild(c);

var r = new CAAT.Foundation.Actor().
setSize(80,80).
setFillStyle('#ff0000').
setScaleAnchor(0, 0). // necessary to match corners
setScale(2, 2).
setPosition(0, 0); // place actor to overlay container
c.addChild(r);

I then want to rotate the actor around its center:

r.addBehavior((new CAAT.RotateBehavior()).
setValues(0, 2 * Math.PI).
setDelayTime(0, 10000).
setCycle(true));

This does not work. I assume that my usage of setScaleAnchor() is
wrong, but I haven't found any other way to make setPosition() on a
scaled actor behave as expected.

I attached an example of the problem.

Arne

On Sat, 4 May 2013 12:41:30 -0700 hyperandroid <hypera...@gmail.com>
wrote:
index.html
Reply all
Reply to author
Forward
0 new messages