A CC3NodeSequencer instance organizes nodes that are added to it. More...
#import <CC3NodeSequencer.h>
Public Member Functions | |
(BOOL) | - add:withVisitor: |
(NSString *) | - fullDescription |
(id) | - initWithEvaluator: |
(BOOL) | - remove:withVisitor: |
(void) | - removeMisplacedNodesWithVisitor: |
(BOOL) | - updateSequenceWithVisitor: |
Static Public Member Functions | |
(id) | + sequencer |
(id) | + sequencerWithEvaluator: |
Properties | |
BOOL | allowSequenceUpdates |
CC3NodeEvaluator * | evaluator |
NSArray * | nodes |
A CC3NodeSequencer instance organizes nodes that are added to it.
The node sequencer contains a CC3NodeEvaluator to determine whether it is interested in a node when an attempt is made to add the node. Only nodes that are accepted the evaluator will be added to the sequencer.
The type of sequencing performed is determined by the subclass of CC3NodeSequencer. A wide range of subclasses may be constructed to perform a variety of sequencing techniques.
- (BOOL) add: | (CC3Node *) | aNode | |
withVisitor: | (CC3NodeSequencerVisitor *) | visitor | |
Adds the specified node to this sequencer if the node is accepted by the contained evaluator.
If the node is rejected by the evaluator, it is not added. Returns whether the node was added.
- (NSString*) fullDescription |
Returns a string containing a more complete description of this object.
- (id) initWithEvaluator: | (CC3NodeEvaluator *) | anEvaluator |
Initializes this instance with the specified evaluator.
- (BOOL) remove: | (CC3Node *) | aNode | |
withVisitor: | (CC3NodeSequencerVisitor *) | visitor | |
Removes the specified node, if it exists within this sequencer, and returns whether it was removed.
- (void) removeMisplacedNodesWithVisitor: | (CC3NodeSequencerMisplacedNodeVisitor *) | visitor |
If the allowSequenceUpdates is set to YES, looks for nodes that are misplaced in this sequencer, removes them from this sequencer, and adds them to the misplacedNodes property of the specified visitor.
What it means for a node to be "misplaced" is defined by the sequencer subclass. A sequencer subclasses may determine that the node no longer meets the criteria of the sequencer's evaluator, or that the node is now out of order, relative to the sorting or grouping criteria defined by the sequencer.
The default behaviour is to do nothing. Subclasses will override as necessary.
This method is invoked automatically by the updateSequenceWithVisitor: method. The application should never need to invoke this method directly.
+ (id) sequencer |
Allocates and initializes an autoreleased instance with no evaluator.
This sequencer will not accept any nodes until an evaluator is attached.
+ (id) sequencerWithEvaluator: | (CC3NodeEvaluator *) | anEvaluator |
Allocates and initializes an autoreleased instance with the specified evaluator.
- (BOOL) updateSequenceWithVisitor: | (CC3NodeSequencerMisplacedNodeVisitor *) | visitor |
Invokes the removeMisplacedNodesWithVisitor: method on this sequencer to look for and remove nodes that are "misplaced", then re-adds those misplaced nodes back into this sequencer, so that they can be inserted into their correct sequence position.
This method is invoked automatically from the CC3World on each drawing frame. The application should never need to invoke this method directly.
- (BOOL) allowSequenceUpdates [read, write, assign] |
Indicates that the sequencer will run the algorithm to relocate misplaced nodes when the updateSequenceWithVisitor: method is invoked.
Setting this property to NO means that when updateSequenceWithVisitor: is invoked, on this or a parent sequencer, no attempt will be made to move misplaced nodes in this sequencer to their correct drawing sequence position.
Initially, this property is set to YES to ensure nodes are always in their correct drawing sequence position, to avoid unexpected visual artifacts.
However, the updateSequenceWithVisitor: method is invoked on each drawing frame, and checks each drawable node. You may find performance improvements by setting this property to NO on some sequencers, if you know that the nodes contained in a particular sequencer will not be moved out of that sequencer, or re-sorted within that sequencer, and you want to save the overhead of checking each node on each drawing frame.
If you have set this property to NO, you can still force a node to be re-positioned to its correct drawing sequence position by invoking the checkDrawingOrder method on the node.
- (CC3NodeEvaluator *) evaluator [read, write, retain] |
The evaluator that determines whether a node should be added to this sequencer.
If no evaluator is attached to this sequencer, no nodes will be added.
- (NSArray*) nodes [read, assign] |
An array of the nodes that have been added to this sequencer, ordered as this sequencer defines.
Implemented in CC3NodeArraySequencer.