Cycling objects

The animation of an object is called "cycling". This is the successive display of several cels from the same loop in order. When you initialize an object, it cycles the cels in the first loop (loop 0) by default. To change the loop number, use the set.loop command. To change the speed of cycling, use the cycle.time command. If you want to display a single cel without animation, set the loop number and cel number you want to display using the set.loop and set.cel commands and then use the stop.cycling command (you can start cycling again by using the start.cycling command).

Here is an example of initializing an object that displays cel 2 of loop 1 without animating:

animate.obj(o2);
load.view(4);
set.view(o2,4);
position(o2,80,120);
set.loop(o2,1);
set.cel(o2,2);
draw(o2);
stop.cycling(o2);

The objects aren't updated on screen until the start of the next cycle (or until the force.update command is issued), so whatever changes you make to an object's position or appearance do not take affect till then.

Normally when an object is moving around, it's loop number is determined by it's direction:

Direction       Loop no
---------------------------
0 (not moving)  not changed
1 (up)          3 (if loop 2 and 3 exist) otherwise not changed
2 (up-right)    0
3 (right)       0
4 (down-right)  0
5 (down)        2 (if loop 2 and 3 exist) otherwise not changed
6 (down-left)   1 (if loop 1 exists) otherwise 0
7 (left)        1 (if loop 1 exists) otherwise 0
8 (up-left)     1 (if loop 1 exists) otherwise 0

The direction is only chosen automatically if there are less than 5 loops in the view assigned to the object.

To stop the interpreter from chosing a loop number based on the object's direction, use the fix.loop command. To let it chose the loop number, use the release.loop command.

To play the animation in reverse, use the reverse.cycle command. To play it forwards again, use the normal.cycle command.

To play the animation once and then stop cycling, use the end.of.loop or reverse.loop commands.

See also

set.loop

set.loop.v

set.cel

set.cel.v

cycle.time

start.cycling

stop.cycling

force.update

normal.cycle

reverse.cycle

end.of.loop

reverse.loop

Objects