Script Classes for Adventure Games/Cycling Classes
Author: Jeff Stephenson
The Cycling Classes
The Cycle class is the basic class which implements cycling behavior in Actor and its sub-classes. Sub-classes of Cycle implement specific cycling behavior.
callerThe object to be cue:ed when the Cycle completes.
clientThe Prop, Actor, etc. which is being cycled by an instance of Cycle.
cycleDirThe direction in which the client's cels are to be cycled.1 forward (cel numbers should increase)
-1 backward (cel numbers should decrease)
cycleCntThe number of animation cycles since the current cel of the client was displayed. When this equals the cycleSpeed of the client, the nextCel: method is invoked.
init:Do any necessary initialization of the Cycle class and ensure that the client is updating.
doit:Called by the client as doit: self, this method sets the cel of the client to the appropriate value based on the particular Cycle class.
nextCel:Used by the doit: method to move the cel number in the direction indicated by cycleDir.
cycleDone:This is invoked when the client's cel reaches a destination cel. If the Cycle class is one of the cyclic ones, this just wraps the cel to either the beginning or end of the current loop. If it is a terminating Cycle class, this cue:s the caller.
Cycles an Actor through its cels in the 'normal' order — from 0 through the end of the loop and back to 0. Set with (actor setCycle:Forward).
This is a Forward cycle type which only cycles an Actor when the Actor is moving. Set with (actor setCycle:Walk).
Cycles an Actor through its cels in the reverse order of that in Forward, i.e. from the highest cel number to 0 and then repeating. Set with (actor setCycle:Reverse).
This class allows you to cycle to an arbitrary cel and stop. It is set by (actor setCycle:CycleTo toCel direction [caller]).
endCelThe number of the cel at which the cycling is to complete.
This sub-class of CycleTo advances the cel of an Actor from the current cel to the cel which is the end of the current loop for the Actor, then stops and cue:s its caller (if it has one). Set with (actor setCycle:EndLoop [caller]).
This sub-class of CycleTo decrements the cel number from its current value to 0, then stops and cue:s its caller, if any. Set with (actor setCycle:BegLoop [caller]).