C# Класс 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.
Наследование: DisplayObjectContainer
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
ClipRect Sparrow.Geom.Rectangle

Открытые методы

Метод Описание
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.

Описание методов

BoundsInSpace() публичный Метод

public BoundsInSpace ( DisplayObject targetSpace ) : Rectangle
targetSpace DisplayObject
Результат Sparrow.Geom.Rectangle

ClipRectInSpace() публичный Метод

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
Результат Sparrow.Geom.Rectangle

Flatten() публичный Метод

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
Результат void

HitTestPoint() публичный Метод

public HitTestPoint ( Point localPoint ) : DisplayObject
localPoint Sparrow.Geom.Point
Результат DisplayObject

Render() публичный Метод

public Render ( RenderSupport support ) : void
support Sparrow.Core.RenderSupport
Результат void

Unflatten() публичный Метод

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
Результат void

Описание свойств

ClipRect публичное свойство

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
Результат Sparrow.Geom.Rectangle