Class DisplayObjectContainer

  • All Implemented Interfaces:
    Drawable
    Direct Known Subclasses:
    Stage

    public class DisplayObjectContainer
    extends DisplayObject
    Base class for collection of DisplayObjects. DisplayObjectContainer does not have anything drawable for itself but it can contain many drawables inside, it's bounds are calulated by it's children. Using DisplayObjectContainer is not recommended as long as it has a lot of overhead for creating new arrays, use it when you want to group DisplayObjects together.
    See Also:
    DisplayObject
    • Field Detail

      • children

        protected final java.util.ArrayList<DisplayObject> children
        Array of children in this container.
    • Constructor Detail

      • DisplayObjectContainer

        public DisplayObjectContainer()
    • Method Detail

      • getChildrenCount

        public int getChildrenCount()
        Current children count.
        Returns:
        integer
      • contains

        public java.lang.Boolean contains​(DisplayObject child)
        Checks if given DisplayObject already exists in this container.
      • getChildAt

        public DisplayObject getChildAt​(int index)
        Get child at given index.
      • getChildIndex

        public int getChildIndex​(DisplayObject child)
        Gets index of a given DisplayObject.
      • removeChildAt

        public DisplayObject removeChildAt​(int index)
        Removes a child from given index.
      • removeChildren

        public void removeChildren()
        Clears the container.
      • swapChildrenAt

        public void swapChildrenAt​(int index1,
                                   int index2)
        Swap children with their given indices.
      • getChildren

        public java.util.ArrayList<DisplayObject> getChildren()
        Get a list of all children in this container.