How do I make something rotate?
Added: 31 Jan 2009. Working example for Java
Changing the orientation of an object, as with changing size makes use of coordinate transforms.
transform = new FSCoordTransform(x, y);
transform.rotate(15.0);
movie.add(new FSPlaceObject(rectangle.getIdentifier(), 2, transform));
movie.add(new FSShowFrame());
Transform allows you to specify the angle in degrees. It then converted to radians before before used to create the transform.
int angle = 0;
int delta = 15;
int steps = 360/delta;
for (int i=0; i<steps; i++)
{
angle += delta;
transform = new FSCoordTransform(x, y);
transform.rotate(angle);
movie.add(new FSPlaceObject2(1, transform));
movie.add(FSShowFrame.getInstance());
}
Creating an animation to rotate an object uses the same process as changing its size - the angle of rotation is updated and used to generate a coordinate transform which changes the original definition of the object - not the previous transform applied.