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
Afficher le fichier Open project: fmotagarcia/sparrow-sharp Class Usage Examples

Méthodes publiques

Свойство Type Description
ClipRect Sparrow.Geom.Rectangle

Méthodes publiques

Méthode 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 méthode

public BoundsInSpace ( DisplayObject targetSpace ) : Rectangle
targetSpace DisplayObject
Résultat Sparrow.Geom.Rectangle

ClipRectInSpace() public méthode

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
Résultat Sparrow.Geom.Rectangle

Flatten() public méthode

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
Résultat void

HitTestPoint() public méthode

public HitTestPoint ( Point localPoint ) : DisplayObject
localPoint Sparrow.Geom.Point
Résultat DisplayObject

Render() public méthode

public Render ( RenderSupport support ) : void
support Sparrow.Core.RenderSupport
Résultat void

Unflatten() public méthode

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
Résultat 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
Résultat Sparrow.Geom.Rectangle