Package com.nevergarden.myna.display
Class DisplayObject
- java.lang.Object
-
- com.nevergarden.myna.events.EventDispatcher
-
- com.nevergarden.myna.display.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 ofDisplayObject
job is to take care of transformation matrix calculations.
-
-
Field Summary
Fields Modifier and Type Field Description protected DisplayObjectContainer
parent
Parent of current node.protected org.joml.Vector3f
pivot
protected org.joml.Vector3f
position
protected org.joml.Quaternionf
rotation
protected org.joml.Vector3f
scale
protected org.joml.Matrix4f
transform
-
Fields inherited from class com.nevergarden.myna.events.EventDispatcher
eventListeners
-
-
Constructor Summary
Constructors Constructor Description DisplayObject()
Default Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
draw(int frame)
Draws the drawable on the given frame.Vector3f
getPosition()
Get position of current object.protected void
recalculateMatrix()
Recalculates the matrix with it's current transformations.void
removeFromParent()
Removes self from parent.void
rotate(float radians)
Rotates current object in radians.void
setLocalX(float x)
Sets current DisplayObject X position relative to it's parent.void
setLocalY(float y)
Sets current DisplayObject Y position relative to it's parent.void
setParent(DisplayObjectContainer parent)
Sets a new parent to this DisplayObjectvoid
setPivot(float x, float y)
Sets Piviot point of current DisplayObjectvoid
setPivotX(float x)
Sets X pivot position of current DisplayObjectvoid
setPivotY(float y)
Sets Y pivot position of current DisplayObjectvoid
setPosition(float x, float y)
Sets position of current DisplayObject relative to it's parent.void
setRotation(float radians)
Sets current object rotation in radians.void
setScale(float x, float y)
Sets current object scale.void
setScaleX(float x)
Sets current object X scale.void
setScaleY(float y)
Sets current object Y scale.-
Methods inherited from class com.nevergarden.myna.events.EventDispatcher
addEventListener, dispatchEvent, dispatchEventWith, dispatchEventWith, dispose, hasEventListener, invokeEvent, removeEventListener, removeEventListeners
-
-
-
-
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.
-
-
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.
-
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.
-
-