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). When an animation is completed, it throws it away.

There is a default juggler in every stage. You can access it by calling

SPJuggler *juggler = self.stage.juggler;

in any object that has access to the stage. 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];

The Sparrow blog contains three extensive articles about the juggler:

  • http://www.sparrow-framework.org/2010/08/tweens-jugglers-animating-your-stage/
  • http://www.sparrow-framework.org/2010/09/tweens-jugglers-an-in-depth-look-at-the-juggler/
  • http://www.sparrow-framework.org/2010/10/tweens-jugglers-unleashed/

Tasks

Initializers

Methods

Properties

Properties

elapsedTime

The total life time of the juggler.

@property (nonatomic, readonly) double elapsedTime

Discussion

The total life time of the juggler.

Declared In

SPJuggler.h

Class Methods

juggler

Factory method.

+ (SPJuggler *)juggler

Discussion

Factory method.

Declared In

SPJuggler.h

Instance Methods

addObject:

Adds an object to the juggler.

- (void)addObject:(id<SPAnimatable>)object

Discussion

Adds an object to the juggler.

Declared In

SPJuggler.h

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 time has passed.

- (id)delayInvocationAtTarget:(id)target byTime:(double)time

Discussion

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.h

removeAllObjects

Removes all objects at once.

- (void)removeAllObjects

Discussion

Removes all objects at once.

Declared In

SPJuggler.h

removeObject:

Removes an object from the juggler.

- (void)removeObject:(id<SPAnimatable>)object

Discussion

Removes an object from the juggler.

Declared In

SPJuggler.h

removeObjectsWithTarget:

Removes all objects with a target property referencing a certain object (e.g. tweens or delayed invocations).

- (void)removeObjectsWithTarget:(id)object

Discussion

Removes all objects with a target property referencing a certain object (e.g. tweens or delayed invocations).

Declared In

SPJuggler.h

removeTweensWithTarget:

Removes all objects of type SPTween that have a certain target. DEPRECATED! Use removeObjectsWithTarget instead.

- (void)removeTweensWithTarget:(id)object

Discussion

Removes all objects of type SPTween that have a certain target. DEPRECATED! Use removeObjectsWithTarget instead.

Declared In

SPJuggler.h