SPJuggler Class Reference
| Inherits from | NSObject |
| Conforms to | SPAnimatable |
| Declared in | SPJuggler.h |
Overview
The SPJuggler takes objects that implement SPAnimatable (e.g. SPTweens) and executes them.
A juggler is a simple object. It does no more than saving a list of objects implementing
SPAnimatable and advancing their time if it is told to do so (by calling its own advanceTime:
method). Furthermore, an object can request to be removed from the juggler by dispatching an
SPEventTypeRemoveFromJuggler event.
There is a default juggler that you can access from anywhere with the following code:
SPJuggler *juggler = Sparrow.juggler;
You can, however, create juggler objects yourself, too. That way, you can group your game into logical components that handle their animations independently.
A cool feature of the juggler is to delay method calls. Say you want to remove an object from its parent 2 seconds from now. Call:
[[juggler delayInvocationAtTarget:object byTime:2.0] removeFromParent];
This line of code will execute the following method 2 seconds in the future:
[object removeFromParent];
Alternatively, you can use the block-based verson of the method:
[juggler delayInvocationByTime:2.0 block:^{ [object removeFromParent]; };
Tasks
Initialization
-
+ jugglerFactory method.
Methods
-
– addObject:Adds an object to the juggler.
-
– removeObject:Removes an object from the juggler.
-
– removeAllObjectsRemoves all objects at once.
-
– removeObjectsWithTarget:Removes all objects with a
targetproperty referencing a certain object (e.g. tweens or delayed invocations). -
– containsObject:Determines if an object has been added to the juggler.
-
– delayInvocationAtTarget:byTime:Delays the execution of a certain method. Returns a proxy object on which to call the method instead. Execution will be delayed until
timehas passed. -
– delayInvocationByTime:block:Delays the execution of a block by a certain time in seconds.
Properties
-
elapsedTimeThe total life time of the juggler.
property -
speedThe speed factor adjusts how fast a juggler’s animatables run. For example, a speed factor of 2.0 means the juggler runs twice as fast.
property
Properties
elapsedTime
The total life time of the juggler.
@property (nonatomic, readonly) double elapsedTimeDiscussion
The total life time of the juggler.
Declared In
SPJuggler.hspeed
The speed factor adjusts how fast a juggler’s animatables run. For example, a speed factor of 2.0 means the juggler runs twice as fast.
@property (nonatomic, assign) float speedDiscussion
The speed factor adjusts how fast a juggler’s animatables run. For example, a speed factor of 2.0 means the juggler runs twice as fast.
Declared In
SPJuggler.hInstance Methods
addObject:
Adds an object to the juggler.
- (void)addObject:(id<SPAnimatable>)objectDiscussion
Adds an object to the juggler.
Declared In
SPJuggler.hcontainsObject:
Determines if an object has been added to the juggler.
- (BOOL)containsObject:(id<SPAnimatable>)objectDiscussion
Determines if an object has been added to the juggler.
Declared In
SPJuggler.hdelayInvocationAtTarget:byTime:
Delays the execution of a certain method. Returns a proxy object on which to call the method
instead. Execution will be delayed until time has passed.
- (id)delayInvocationAtTarget:(id)target byTime:(double)timeDiscussion
Delays the execution of a certain method. Returns a proxy object on which to call the method
instead. Execution will be delayed until time has passed.
Declared In
SPJuggler.hdelayInvocationByTime:block:
Delays the execution of a block by a certain time in seconds.
- (id)delayInvocationByTime:(double)time block:(SPCallbackBlock)blockDiscussion
Delays the execution of a block by a certain time in seconds.
Declared In
SPJuggler.hremoveAllObjects
Removes all objects at once.
- (void)removeAllObjectsDiscussion
Removes all objects at once.
Declared In
SPJuggler.hremoveObject:
Removes an object from the juggler.
- (void)removeObject:(id<SPAnimatable>)objectDiscussion
Removes an object from the juggler.
Declared In
SPJuggler.hremoveObjectsWithTarget:
Removes all objects with a target property referencing a certain object (e.g. tweens or
delayed invocations).
- (void)removeObjectsWithTarget:(id)objectDiscussion
Removes all objects with a target property referencing a certain object (e.g. tweens or
delayed invocations).
Declared In
SPJuggler.h