java.lang.Object

public class Entity
extends Physics
Entity to be placed in a Scene, with Physics and a Sprite
  • Constructor Details

    • Entity

      public Entity()
      Create a new default Entity
    • Entity

      public Entity​(Entity entity)
      Copy constructor for Entities
      Parameters:
      entity - Entity to copy
  • Method Details

    • getSprite

      public Sprite getSprite()
      Get the Sprite of the Entity
      Returns:
      Sprite of the Entity
    • setSprite

      public Entity setSprite​(Sprite sprite)
      Set the Sprite for the Entity
      Parameters:
      sprite - New Sprite
      Returns:
      This Entity
    • isOnScreen

      public boolean isOnScreen()
      Check if the Entity is shown on-screen
      If the Entity has no Sprite, this will always be false
      Returns:
      True if shown on-screen
    • setOnScreen

      public void setOnScreen​(boolean onScreen)
      Set if the Entity is on-screen
      Manually setting this will do nothing, as this value is automatically updated by the Renderer
      Parameters:
      onScreen - True when visible on-screen
    • canUpdateOffScreen

      public boolean canUpdateOffScreen()
      Get whether the Entity can update when not visible on-screen
      Returns:
      True if the Entity can update off-screen
    • setUpdateOffScreen

      public Entity setUpdateOffScreen​(boolean updateOffScreen)
      Set whether the Entity can update when not visible on-screen
      Parameters:
      updateOffScreen - True to allow updating off-screen
      Returns:
      This Entity
    • setScene

      public Entity setScene​(Scene scene)
      Set the Scene the Entity is in
      Parameters:
      scene - Scene to place Entity in
      Returns:
      This Entity
    • getScene

      public Scene getScene()
      Get the Scene the Entity is in
      Returns:
      Scene Entity is in
    • getSpeed

      public float getSpeed()
      Get the speed modifier of the Entity for physics and rendering
      Returns:
      Speed modifier value
    • setSpeed

      public Entity setSpeed​(float speed)
      Set the speed modifier for the Entity for physics and rendering
      Parameters:
      speed - New speed modifier value
      Returns:
      This Entity
    • tickMotion

      public void tickMotion​(float deltaTime)
      Update the motion of the Entity
      Overrides:
      tickMotion in class Physics
      Parameters:
      deltaTime - Time elapsed of the previous tick
    • isEnabled

      public boolean isEnabled()
      Check if the Entity is enabled in the Scene
      Returns:
      True if enabled
    • setEnabled

      public Entity setEnabled​(boolean enabled)
      Set the Entity to be visible in the Scene and updatable in Physics
      Parameters:
      enabled - True to enable Entity in Scene
      Returns:
      This Entity
    • isVisible

      public boolean isVisible()
      Check if the Entity is visible in rendering
      Returns:
      True if visible
    • setVisible

      public Entity setVisible​(boolean visible)
      Set the Entity to be visible in rendering
      Returns:
      This Entity
    • hasPhysics

      public boolean hasPhysics()
      Check if the Entity has physics enabled
      Returns:
      True if Entity has physics
    • setPhysics

      public Entity setPhysics​(boolean enabled)
      Set the Entity to have physics or not
      Parameters:
      enabled - True to enable physics
      Returns:
      This Entity
    • equals

      public boolean equals​(java.lang.Object o)
      Check if this Entity is identical to another
      Overrides:
      equals in class Physics
      Parameters:
      o - Entity to check
      Returns:
      True if this Entity is identical to the other Entity