C# Класс Sparrow.Display.DisplayObject

The DisplayObject class is the base class for all objects that are rendered on the screen. In Sparrow, all displayable objects are organized in a display tree. Only objects that are part of the display tree will be displayed (rendered). The display tree consists of leaf nodes (Image, Quad) that will be rendered directly to the screen, and of container nodes (subclasses of DisplayObjectContainer, like Sprite). A container is simply a display object that has child nodes - which can, again, be either leaf nodes or other containers. A display object has properties that define its position in relation to its parent ('X', 'Y'), as well as its rotation, skewing and scaling factors. Use the 'Alpha' and 'Visible' properties to make an object translucent or invisible. Every display object may be the target of touch events. If you don't want an object to be touchable, you can disable the `Touchable` property. When it's disabled, neither the object nor its children will receive any more touch events. **Points vs. Pixels** All sizes and distances are measured in points. What this means in pixels depends on the contentScaleFactor of the device. **Transforming coordinates** Within the display tree, each object has its own local coordinate system. If you rotate a container, you rotate that coordinate system - and thus all the children of the container. Sometimes you need to know where a certain point lies relative to another coordinate system. That's the purpose of the method 'TransformationMatrixToSpace'. It will create a matrix that represents the transformation of a point in one coordinate system to another. **Subclassing DisplayObject** As DisplayObject is an abstract class, you can't instantiate it directly, but have to use one of its subclasses instead. However, you can create custom display objects as well. That's especially useful when you want to create an object with a custom render function. You will need to implement the following methods when you subclass DisplayObject: - void Render ( RenderSupport support); - Rectangle BoundsInSpace ( DisplayObject targetSpace); Have a look at Quad for a sample implementation of those methods.
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
BlendMode uint
Filter SparrowSharp.Filters.FragmentFilter
Name string
Touchable bool
Visible bool

Защищенные свойства (Protected)

Свойство Тип Описание
_alpha float

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

Метод Описание
Align ( HAlign hAlign, VAlign vAlign ) : void

Moves the pivot point to a certain position within the local coordinate system of the object.

AlignPivotToCenter ( ) : void

Moves the pivot point to the center of the object.

BoundsInSpace ( DisplayObject targetSpace ) : Rectangle

Returns a rectangle that completely encloses the object as it appears in another coordinate system.

GlobalToLocal ( Point globalPoint ) : Point

Transforms a point from global (stage) coordinates to the local coordinate system.

HitTestPoint ( Point localPoint ) : DisplayObject

Returns the object that is found topmost on a point in local coordinates, or null if the test fails.

LocalToGlobal ( Point localPoint ) : Point

Transforms a point from the local coordinate system to global (stage) coordinates.

RemoveFromParent ( ) : void

Removes the object from its parent, if it has one.

Render ( RenderSupport support ) : void

Renders the display object with the help of a support object.

TransformationMatrixToSpace ( DisplayObject targetSpace ) : Matrix

Creates a matrix that represents the transformation from the local coordinate system to another.

Защищенные методы

Метод Описание
DisplayObject ( ) : System

Приватные методы

Метод Описание
BroadcastAddedToStageEvent ( DisplayObjectContainer currentTarget ) : void
BroadcastEnterFrameEvent ( float passedTime ) : void
BroadcastRemovedFromStageEvent ( DisplayObjectContainer currentTarget ) : void
InvokeAdded ( DisplayObject target, DisplayObject currentTarget ) : void
InvokeKeyDown ( DisplayObject target, DisplayObject currentTarget ) : void
InvokeKeyUp ( DisplayObject target, DisplayObject currentTarget ) : void
InvokeRemoved ( ) : void
InvokeTouch ( TouchEvent touchEvent ) : void

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

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

Moves the pivot point to a certain position within the local coordinate system of the object.
public Align ( HAlign hAlign, VAlign vAlign ) : void
hAlign HAlign
vAlign VAlign
Результат void

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

Moves the pivot point to the center of the object.
public AlignPivotToCenter ( ) : void
Результат void

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

Returns a rectangle that completely encloses the object as it appears in another coordinate system.
public abstract BoundsInSpace ( DisplayObject targetSpace ) : Rectangle
targetSpace DisplayObject
Результат Sparrow.Geom.Rectangle

DisplayObject() защищенный Метод

protected DisplayObject ( ) : System
Результат System

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

Transforms a point from global (stage) coordinates to the local coordinate system.
public GlobalToLocal ( Point globalPoint ) : Point
globalPoint Point
Результат Point

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

Returns the object that is found topmost on a point in local coordinates, or null if the test fails.
public HitTestPoint ( Point localPoint ) : DisplayObject
localPoint Point
Результат DisplayObject

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

Transforms a point from the local coordinate system to global (stage) coordinates.
public LocalToGlobal ( Point localPoint ) : Point
localPoint Point
Результат Point

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

Removes the object from its parent, if it has one.
public RemoveFromParent ( ) : void
Результат void

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

Renders the display object with the help of a support object.
public abstract Render ( RenderSupport support ) : void
support Sparrow.Core.RenderSupport
Результат void

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

Creates a matrix that represents the transformation from the local coordinate system to another.
public TransformationMatrixToSpace ( DisplayObject targetSpace ) : Matrix
targetSpace DisplayObject
Результат Matrix

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

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

The blend mode determines how the object is blended with the objects underneath. Default: BlendMode.AUTO
public uint BlendMode
Результат uint

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

The filter that is attached to the display object. Beware that you should NOT use the same filter on more than one object (for performance reasons).
public FragmentFilter,SparrowSharp.Filters Filter
Результат SparrowSharp.Filters.FragmentFilter

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

The name of the display object (default: null). Used by 'GetChild(string name)' of display object containers.
public string Name
Результат string

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

Indicates if this object (and its children) will receive touch events.
public bool Touchable
Результат bool

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

The visibility of the object. An invisible object will be untouchable.
public bool Visible
Результат bool

_alpha защищенное свойство

protected float _alpha
Результат float