Compiled Sprites

Performance-junkies will be happy about the class “SPCompiledSprite”. As the name suggests, the class works just like “SPSprite” — you can add other display objects to it, other sprites, etc. However, there’s one new method: “compile”.

Whenever you call that method (or automatically on rendering if you did not call it manually), 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 compiled, 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 “compile” again to see them. 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.


Next section: The Scaffold Project

  manual_v1/compiled_sprites.txt · Last modified: 2013/03/05 10:19 (external edit)
 
Powered by DokuWiki