Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
manual:flattened_sprites [2013/05/29 13:32]
daniel
manual:flattened_sprites [2013/05/29 16:13] (current)
daniel
Line 1: Line 1:
 +====== Flattened Sprites ======
  
 +Performance-junkies will be happy about the method "​flatten"​ of the SPSprite class.
 +
 +Whenever you call that method, the class will optimize the rendering of its children so that the number of OpenGL calls that have to be executed is minimal. That means that everything will be rendered extremely fast. And I mean it --- you can expect even complex objects to render as fast as if it was just a single SPImage.
 +
 +Of course, this comes at a price: once flattened, you will not be able to see any changes you make to the children. You can still move the sprite, scale it, rotate it, etc. --- but not its children. If you make any changes to its children, you have to call "​flatten"​ again to see the changes, or "​unflatten"​ the sprites. ​
 +
 +Thus, it's primarily intended for static geometry that does not (or rarely) change. Internally, Sparrow makes use of this feature when rendering bitmap fonts.
 +
 +<code objc>
 +SPSprite *sprite = [SPSprite sprite];
 +[sprite addChild:​anObject];​
 +[sprite addChild:​anotherObject];​
 +
 +[sprite flatten]; ​  // optimize
 +[sprite unflatten]; // restore normal behaviour
 +</​code>​
 +
 +-----
 +
 +//Next section: [[Performance Optimization]]//​
  manual/flattened_sprites.txt · Last modified: 2013/05/29 16:13 by daniel
 
Powered by DokuWiki