C# 클래스 Sparrow.Display.DisplayObjectContainer

A DisplayObjectContainer represents a collection of display objects. It is the base class of all display objects that act as a container for other objects. By maintaining an ordered list of children, it defines the back-to-front positioning of the children within the display tree. A container does not have size in itself. The width and height properties represent the extents of its children. Changing those properties will scale all children accordingly. As this is an abstract class, you can't instantiate it directly, but have to use a subclass instead. The most lightweight container class is Sprite. **Adding and removing children** The class defines methods that allow you to add or remove children. When you add a child, it will be added at the foremost position, possibly occluding a child that was added before. You can access the children via an index. The first child will have index 0, the second child index 1, etc. Adding and removing objects from a container triggers events. - 'Added': the object was added to a DisplayObjectContainer. - 'AddedToStage': the object was added to a DisplayObjectContainer that is connected to the stage. - 'Removed': the object was removed from a DisplayObjectContainer. - 'RemovedFromStage': the object was removed from a DisplayObjectContainer that is connected to the stage. Especially the AddedToStage event is very helpful, as it allows you to automatically execute some logic (e.g. start an animation) when an object is rendered the first time. **Sorting children** The 'sortChildren' method allows you to sort the children of a container by a custom criteria. Below is an example how to depth-sort children by their y-coordinate; this will put objects that are lower on the screen in front of those higher on the screen. public class CompareExample : IComparator { public int Compare(DisplayObject child1, DisplayObject child2) { if (child1.Y < child2.Y) return -1; else if (child1.Y > child2.Y) return 1; else return 0; } }
상속: DisplayObject
파일 보기 프로젝트 열기: fmotagarcia/sparrow-sharp 1 사용 예제들

공개 메소드들

메소드 설명
AddChild ( DisplayObject child ) : void

Adds a child to the container. It will be at the topmost position.

AddChild ( DisplayObject child, int index ) : void

Adds a child to the container at a certain index.

BoundsInSpace ( DisplayObject targetSpace ) : Rectangle
ContainsChild ( DisplayObject child ) : bool

Determines if a certain object is a child of this container (recursively).

GetChild ( String name ) : DisplayObject

Returns a child object with a certain name (non-recursively).

GetChild ( int index ) : DisplayObject

Returns a child object at a certain index.

GetChild ( uint index ) : DisplayObject

Returns a child object at a certain index.

GetChildIndex ( DisplayObject child ) : int

Returns the index of a child within the container. Returns -1 if the child is not within this container

HitTestPoint ( Point localPoint ) : DisplayObject
RemoveAllChildren ( ) : void

Removes all children from the container.

RemoveChild ( DisplayObject child ) : void

Removes a child from the container. If the object is not a child, nothing happens.

RemoveChildAt ( int index ) : void

Removes a child at a certain index. Children above the child will move down.

Render ( RenderSupport support ) : void
SetChildIndex ( DisplayObject child, int index ) : void

Moves a child to a certain index. Children at and after the replaced position move up. throws ArgumentException if the child is not found

SortChildren ( IComparer comparator ) : void

Sorts the children using the given IComparer.

SwapChild ( DisplayObject child1, DisplayObject child2 ) : void

Swaps the indexes of two children.

SwapChildrenAt ( int index1, int index2 ) : void

Swaps the indexes of two children.

메소드 상세

AddChild() 공개 메소드

Adds a child to the container. It will be at the topmost position.
public AddChild ( DisplayObject child ) : void
child DisplayObject
리턴 void

AddChild() 공개 메소드

Adds a child to the container at a certain index.
public AddChild ( DisplayObject child, int index ) : void
child DisplayObject
index int
리턴 void

BoundsInSpace() 공개 메소드

public BoundsInSpace ( DisplayObject targetSpace ) : Rectangle
targetSpace DisplayObject
리턴 Sparrow.Geom.Rectangle

ContainsChild() 공개 메소드

Determines if a certain object is a child of this container (recursively).
public ContainsChild ( DisplayObject child ) : bool
child DisplayObject
리턴 bool

GetChild() 공개 메소드

Returns a child object with a certain name (non-recursively).
public GetChild ( String name ) : DisplayObject
name String
리턴 DisplayObject

GetChild() 공개 메소드

Returns a child object at a certain index.
public GetChild ( int index ) : DisplayObject
index int
리턴 DisplayObject

GetChild() 공개 메소드

Returns a child object at a certain index.
public GetChild ( uint index ) : DisplayObject
index uint
리턴 DisplayObject

GetChildIndex() 공개 메소드

Returns the index of a child within the container. Returns -1 if the child is not within this container
public GetChildIndex ( DisplayObject child ) : int
child DisplayObject
리턴 int

HitTestPoint() 공개 메소드

public HitTestPoint ( Point localPoint ) : DisplayObject
localPoint Point
리턴 DisplayObject

RemoveAllChildren() 공개 메소드

Removes all children from the container.
public RemoveAllChildren ( ) : void
리턴 void

RemoveChild() 공개 메소드

Removes a child from the container. If the object is not a child, nothing happens.
public RemoveChild ( DisplayObject child ) : void
child DisplayObject
리턴 void

RemoveChildAt() 공개 메소드

Removes a child at a certain index. Children above the child will move down.
public RemoveChildAt ( int index ) : void
index int
리턴 void

Render() 공개 메소드

public Render ( RenderSupport support ) : void
support Sparrow.Core.RenderSupport
리턴 void

SetChildIndex() 공개 메소드

Moves a child to a certain index. Children at and after the replaced position move up. throws ArgumentException if the child is not found
public SetChildIndex ( DisplayObject child, int index ) : void
child DisplayObject
index int
리턴 void

SortChildren() 공개 메소드

Sorts the children using the given IComparer.
public SortChildren ( IComparer comparator ) : void
comparator IComparer
리턴 void

SwapChild() 공개 메소드

Swaps the indexes of two children.
public SwapChild ( DisplayObject child1, DisplayObject child2 ) : void
child1 DisplayObject
child2 DisplayObject
리턴 void

SwapChildrenAt() 공개 메소드

Swaps the indexes of two children.
public SwapChildrenAt ( int index1, int index2 ) : void
index1 int
index2 int
리턴 void