C# Class 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.
ファイルを表示 Open project: fmotagarcia/sparrow-sharp Class Usage Examples

Public Properties

Property Type Description
BlendMode uint
Filter SparrowSharp.Filters.FragmentFilter
Name string
Touchable bool
Visible bool

Protected Properties

Property Type Description
_alpha float

Public Methods

Method Description
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.

Protected Methods

Method Description
DisplayObject ( ) : System

Private Methods

Method Description
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

Method Details

Align() public method

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
return void

AlignPivotToCenter() public method

Moves the pivot point to the center of the object.
public AlignPivotToCenter ( ) : void
return void

BoundsInSpace() public abstract method

Returns a rectangle that completely encloses the object as it appears in another coordinate system.
public abstract BoundsInSpace ( DisplayObject targetSpace ) : Rectangle
targetSpace DisplayObject
return Sparrow.Geom.Rectangle

DisplayObject() protected method

protected DisplayObject ( ) : System
return System

GlobalToLocal() public method

Transforms a point from global (stage) coordinates to the local coordinate system.
public GlobalToLocal ( Point globalPoint ) : Point
globalPoint Point
return Point

HitTestPoint() public method

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
return DisplayObject

LocalToGlobal() public method

Transforms a point from the local coordinate system to global (stage) coordinates.
public LocalToGlobal ( Point localPoint ) : Point
localPoint Point
return Point

RemoveFromParent() public method

Removes the object from its parent, if it has one.
public RemoveFromParent ( ) : void
return void

Render() public abstract method

Renders the display object with the help of a support object.
public abstract Render ( RenderSupport support ) : void
support Sparrow.Core.RenderSupport
return void

TransformationMatrixToSpace() public method

Creates a matrix that represents the transformation from the local coordinate system to another.
public TransformationMatrixToSpace ( DisplayObject targetSpace ) : Matrix
targetSpace DisplayObject
return Matrix

Property Details

BlendMode public_oe property

The blend mode determines how the object is blended with the objects underneath. Default: BlendMode.AUTO
public uint BlendMode
return uint

Filter public_oe property

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
return SparrowSharp.Filters.FragmentFilter

Name public_oe property

The name of the display object (default: null). Used by 'GetChild(string name)' of display object containers.
public string Name
return string

Touchable public_oe property

Indicates if this object (and its children) will receive touch events.
public bool Touchable
return bool

Visible public_oe property

The visibility of the object. An invisible object will be untouchable.
public bool Visible
return bool

_alpha protected_oe property

protected float _alpha
return float