Difference between revisions of "Cycling Objects"

From AGI Wiki
Jump to navigationJump to search
 
(2 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
Here is an example of initializing an object that displays cel 2 of loop 1 without animating:
 
Here is an example of initializing an object that displays cel 2 of loop 1 without animating:
  
<blockquote><div class="CodeBlockHeader">Code:</div>
+
<blockquote>
 +
<div class="CodeBlockHeader">Code:</div>
 
<syntaxhighlight lang="agi">
 
<syntaxhighlight lang="agi">
animate.obj(o2);
+
    animate.obj(o2);
load.view(4);
+
    load.view(4);
set.view(o2,4);
+
    set.view(o2,4);
position(o2,80,120);
+
    position(o2,80,120);
set.loop(o2,1);
+
    set.loop(o2,1);
set.cel(o2,2);
+
    set.cel(o2,2);
draw(o2);
+
    draw(o2);
stop.cycling(o2);
+
    stop.cycling(o2);
</syntaxhighlight></blockquote>
+
</syntaxhighlight>
 +
</blockquote>
  
 
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.
 
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:
+
Normally when an object is moving around, it's loop number is determined by it's direction:<br />
  
 
<blockquote>
 
<blockquote>
Line 43: Line 45:
 
|8 (up-left)||1 (if loop 1 exists) otherwise 0
 
|8 (up-left)||1 (if loop 1 exists) otherwise 0
 
|}
 
|}
</blockquote>
+
</blockquote><br />
  
 
The direction is only chosen automatically if there are less than 5 loops in the view assigned to the object.
 
The direction is only chosen automatically if there are less than 5 loops in the view assigned to the object.
Line 67: Line 69:
 
* <code>[[end.of.loop]]</code>
 
* <code>[[end.of.loop]]</code>
 
* <code>[[reverse.loop]]</code>
 
* <code>[[reverse.loop]]</code>
* [[Objects]]
+
* [[Animated Object]]
  
 
&nbsp;
 
&nbsp;

Latest revision as of 23:28, 29 December 2013

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:

Code:

<syntaxhighlight lang="agi"> 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); </syntaxhighlight>

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 choosing 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