Inherits from SPSprite : SPDisplayObjectContainer : SPDisplayObject : SPEventDispatcher : NSObject
Declared in SPCompiledSprite.h

Overview

An SPCompiledSprite allows you to optimize the rendering of static parts of your display list.

It analyzes the tree of children attached to it and optimizes the OpenGL rendering calls in a way that makes rendering them extremely fast. The downside is that you will no longer see any changes in the properties of the children (position, rotation, alpha, etc.). To update the object after changes have happened, simply call compile again.

With the exception of this peculiarity, a compiled sprite can be use just like any other sprite.

SPCompiledSprite *sprite = [SPCompiledSprite sprite];
[sprite addChild:object1];
[sprite addChild:object2];

[sprite compile]; // this call is optional, it will be done on rendering automatically.

If a class needs to do something special before it becomes part of a compiled sprite, it can listen to events with the type SP_EVENT_TYPE_COMPILE. Such an event is dispatched on all children of a compiled sprite before the compilation process begins.

Tasks

Methods

  • – compile

    Compiles the children of the sprite to optimize rendering. After compilation, no changes in the children will show up. Call the method again to make changes visible.

  • + sprite

    Factory method.

Class Methods

sprite

Factory method.

+ (SPCompiledSprite *)sprite

Discussion

Factory method.

Declared In

SPCompiledSprite.h

Instance Methods

compile

Compiles the children of the sprite to optimize rendering. After compilation, no changes in the children will show up. Call the method again to make changes visible.

- (BOOL)compile

Return Value

Returns YES if compilation was successful. On error, it will NSLog the problem.

Discussion

Compiles the children of the sprite to optimize rendering. After compilation, no changes in the children will show up. Call the method again to make changes visible.

Declared In

SPCompiledSprite.h