java.lang.Object
buildengine.utils.Holder<ActorComponent>
buildengine.engine.stage.scene.actor.Actor

public class Actor extends Holder<ActorComponent>
Actors are the objects in a scene. Also referred to as GameObject or Entity. Positioning center-point. The Actor holds a name, the scene its in (witch is declared when added to a scene), a transform, a sprite object, a collision body (visibility bounds by default) and a configuration object.
  • Field Details

    • name

      protected final String name
      Identifier of the Actor
    • scene

      protected Scene scene
      Scene the actor is in. Assessed when added to a scene.
      See Also:
    • transform

      protected final Transform transform
      Transform of the Actor (Relative to world)
    • sprite

      protected final Sprite sprite
      Sprite of the Actor
    • configuration

      protected final Configuration configuration
      Configuration settings for the actor
  • Constructor Details

    • Actor

      public Actor(String name, Transform transform, Sprite sprite, ActorComponent... components)
      Creates a new instance of an Actor object setting the default configuration.
      Parameters:
      name - Name of the actor, doesn't have to be unique
      transform - The transform containing the actor's position, size and rotation
      sprite - Sprite object containing the actor's rendering data
      components - Components to be added to this actor
  • Method Details

    • instance

      public void instance(Transform... transforms)
      Instance an Actor in multiple locations
    • getVisibilityBounds

      public Rectangle[] getVisibilityBounds()
      Gets the visibility bounds as a Rectangle object. Transforming to top-left positioning. Used for collisions.
      Returns:
      The visibility bounds in TL space.
      See Also:
    • getCollisionBounds

      public Rectangle[] getCollisionBounds()
      Gets the collision bounds as a Rectangle object. Transforming to top-left positioning. If no collision body is defined, it returns the visibility bounds. Used for collisions.
      Returns:
      The collision bounds in TL space.
      See Also:
    • getAnchorPoint

      public Vector2f getAnchorPoint()
    • add

      public void add(ActorComponent component)
      Description copied from class: Holder
      Add a t
      Overrides:
      add in class Holder<ActorComponent>
    • registerCollideEvent

      public void registerCollideEvent(CollideEvent collideEvent)
    • getCollideEvents

      public List<CollideEvent> getCollideEvents()
    • clearCollideEvents

      public void clearCollideEvents()
    • getCollisions

      public List<Collision> getCollisions()
    • getName

      public String getName()
    • isActive

      public boolean isActive()
    • setActive

      public void setActive(boolean active)
    • isDestroyed

      public boolean isDestroyed()
    • destroy

      public void destroy()
    • getTransform

      public Transform getTransform()
    • getSprite

      public Sprite getSprite()
    • getScene

      public Scene getScene()
    • setScene

      public void setScene(Scene scene)
    • getInstances

      public Transform[] getInstances()
    • getConfiguration

      public Configuration getConfiguration()
    • toString

      public String toString()
      Overrides:
      toString in class Object