C# Class Sparrow.Display.Sprite

A Sprite is the most lightweight, non-abstract container class. Use it as a simple means of grouping objects together in one coordinate system. Sprite sprite = new Sprite(); // create children Image venus = TextureLoader.LoadLocalImage("../venus.png"); Image mars = TextureLoader.LoadLocalImage("mars.png"); // move children to some relative positions venus.X = 50; mars.X = -20; // add children to the sprite sprite.AddChild(venus); sprite.AddChild(mars); // calculate total width of all children float totalWidth = sprite.Width; // rotate the whole group sprite.Rotation = Math.PI; **Flattened Sprites** The 'Flatten' method allows you to optimize the rendering of static parts of your display list. It analyzes the tree of children attached to the sprite and optimizes the rendering calls in a way that makes rendering extremely fast. The speed-up comes at a price, though: 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 'flatten' again, or 'unflatten' the object.
Inheritance: DisplayObjectContainer
Exibir arquivo Open project: fmotagarcia/sparrow-sharp Class Usage Examples

Public Properties

Property Type Description
ClipRect Sparrow.Geom.Rectangle

Public Methods

Method Description
BoundsInSpace ( DisplayObject targetSpace ) : Rectangle
ClipRectInSpace ( DisplayObject targetSpace ) : Rectangle

Returns the bounds of the container's clipRect in the given coordinate space, or null if the sprite doens't have a clipRect.

Flatten ( ) : void

Optimizes the sprite for optimal rendering performance. Changes in the children of a flattened sprite will not be displayed any longer. For this to happen, either call 'Flatten' again, or 'Unflatten' the sprite. Beware that the actual flattening will not happen right away, but right before the next rendering.

HitTestPoint ( Point localPoint ) : DisplayObject
Render ( RenderSupport support ) : void
Unflatten ( ) : void

Removes the rendering optimizations that were created when flattening the sprite. Changes to the sprite's children will immediately become visible again.

Method Details

BoundsInSpace() public method

public BoundsInSpace ( DisplayObject targetSpace ) : Rectangle
targetSpace DisplayObject
return Sparrow.Geom.Rectangle

ClipRectInSpace() public method

Returns the bounds of the container's clipRect in the given coordinate space, or null if the sprite doens't have a clipRect.
public ClipRectInSpace ( DisplayObject targetSpace ) : Rectangle
targetSpace DisplayObject
return Sparrow.Geom.Rectangle

Flatten() public method

Optimizes the sprite for optimal rendering performance. Changes in the children of a flattened sprite will not be displayed any longer. For this to happen, either call 'Flatten' again, or 'Unflatten' the sprite. Beware that the actual flattening will not happen right away, but right before the next rendering.
public Flatten ( ) : void
return void

HitTestPoint() public method

public HitTestPoint ( Point localPoint ) : DisplayObject
localPoint Sparrow.Geom.Point
return DisplayObject

Render() public method

public Render ( RenderSupport support ) : void
support Sparrow.Core.RenderSupport
return void

Unflatten() public method

Removes the rendering optimizations that were created when flattening the sprite. Changes to the sprite's children will immediately become visible again.
public Unflatten ( ) : void
return void

Property Details

ClipRect public_oe property

The sprite's clipping rectangle in its local coordinate system. Only pixels within this rectangle will be drawn. The clipping rectangle is axis aligned with the screen, so it will not be rotated or skewed if the sprite is.
public Rectangle,Sparrow.Geom ClipRect
return Sparrow.Geom.Rectangle