Class DisplayObject

  • All Implemented Interfaces:
    Drawable
    Direct Known Subclasses:
    DisplayObjectContainer, Quad

    public abstract class DisplayObject
    extends EventDispatcher
    implements Drawable
    Base of every object that is rendered into screen.

    Display Transformations
    The most important part of DisplayObject job is to take care of transformation matrix calculations.
    See Also:
    Quad, Sprite
    • Field Detail

      • transform

        protected org.joml.Matrix4f transform
      • pivot

        protected org.joml.Vector3f pivot
      • rotation

        protected org.joml.Quaternionf rotation
      • scale

        protected org.joml.Vector3f scale
      • position

        protected org.joml.Vector3f position
      • parent

        protected DisplayObjectContainer parent
        Parent of current node. Most of the nodes are added to stage.
    • Constructor Detail

      • DisplayObject

        public DisplayObject()
        Default Constructor.
    • Method Detail

      • recalculateMatrix

        protected void recalculateMatrix()
        Recalculates the matrix with it's current transformations.
      • removeFromParent

        public void removeFromParent()
        Removes self from parent.
      • setParent

        public void setParent​(DisplayObjectContainer parent)
        Sets a new parent to this DisplayObject
        Parameters:
        parent - New Parent
      • draw

        public void draw​(int frame)
        Description copied from interface: Drawable
        Draws the drawable on the given frame.
        Specified by:
        draw in interface Drawable
      • setLocalX

        public void setLocalX​(float x)
        Sets current DisplayObject X position relative to it's parent.
      • setLocalY

        public void setLocalY​(float y)
        Sets current DisplayObject Y position relative to it's parent.
      • setPosition

        public void setPosition​(float x,
                                float y)
        Sets position of current DisplayObject relative to it's parent.
      • setPivotX

        public void setPivotX​(float x)
        Sets X pivot position of current DisplayObject
      • setPivotY

        public void setPivotY​(float y)
        Sets Y pivot position of current DisplayObject
      • setPivot

        public void setPivot​(float x,
                             float y)
        Sets Piviot point of current DisplayObject
      • setRotation

        public void setRotation​(float radians)
        Sets current object rotation in radians.
      • rotate

        public void rotate​(float radians)
        Rotates current object in radians.
      • setScaleX

        public void setScaleX​(float x)
        Sets current object X scale.
      • setScaleY

        public void setScaleY​(float y)
        Sets current object Y scale.
      • setScale

        public void setScale​(float x,
                             float y)
        Sets current object scale.
      • getPosition

        public Vector3f getPosition()
        Get position of current object.