Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Entity

[20:7] extends: Animatable

Wraps FXGL's Entity, the core game-object type in the ECS. Each Entity holds a position (Point2D), rotation, scale, opacity, an arbitrary "type" tag (for collision-handler dispatch), an attached PropertyMap of per-entity variables, and a list of Components that supply its behavior. Aussom users construct Entity directly for ad-hoc setup or get them back from GameWorld.spawn / getEntities. Components extend behavior; see fxgl.Component for the wrapper.

Methods

  • Entity (Ajo = null)

    Creates a new empty Entity at (0, 0), or wraps an existing Entity AussomJavaObject when one is supplied. The Java-side wrap path matches the GameWorld / Input / GameScene / PhysicsWorld wrappers so the engine can hand back an Entity wrapper from wrapAsClass(...) without the no-arg ctor allocating a stray FXGL Entity.

    • @p Ajo is an optional AussomJavaObject around an Entity.
  • adopt (object Ajo)

    Wraps an existing Entity AussomJavaObject.

    • @p Ajo is an AussomJavaObject around an Entity.
    • @r A new wrapper.
  • getX ()

    Returns the entity's X coordinate.

    • @r A double.
  • getY ()

    Returns the entity's Y coordinate.

    • @r A double.
  • setX (double X)

    Sets the entity X coordinate.

    • @p X is a double.
    • @r this object
  • setY (double Y)

    Sets the entity Y coordinate.

    • @p Y is a double.
    • @r this object
  • setPosition (double X, double Y)

    Sets the entity position (X, Y).

    • @p X is the new X.
    • @p Y is the new Y.
    • @r this object
  • translate (double Dx, double Dy)

    Moves the entity by (Dx, Dy).

    • @p Dx is the X delta.
    • @p Dy is the Y delta.
    • @r this object
  • getRotation ()

    Returns the entity rotation in degrees.

    • @r A double.
  • setRotation (double Degrees)

    Sets the entity rotation in degrees.

    • @p Degrees is a double.
    • @r this object
  • rotateBy (double Degrees)

    Rotates the entity by the given delta in degrees.

    • @p Degrees is the delta.
    • @r this object
  • setScaleUniform (double Scale)

    Sets the entity uniform scale.

    • @p Scale is the scale factor.
    • @r this object
  • setOpacity (double Opacity)

    Sets the entity opacity in the range 0.0 to 1.0.

    • @p Opacity is the new opacity.
    • @r this object
  • setZIndex (int Z)

    Sets the entity z-index (rendering order).

    • @p Z is the z-index.
    • @r this object
  • getType ()

    Returns the entity type tag (often a string or enum used by collision handlers and queries).

    • @r The type as a Java Serializable (string or enum), wrapped as an AussomJavaObject.
  • setType (Type)

    Sets the entity type tag.

    • @p Type is the type value (string, enum, etc).
    • @r this object
  • isType (Type)

    Returns whether this entity matches the given type.

    • @p Type is the type to compare against.
    • @r A bool.
  • getProperties ()

    Returns the entity's PropertyMap of game variables.

    • @r A PropertyMap wrapper.
  • addComponent (object ComponentObj)

    Adds a Component to the entity.

    • @p ComponentObj is a Component wrapper (or AussomJavaObject around a raw FXGL Component).
    • @r this object
  • addBoundingBox (double Width, double Height)

    Adds an axis-aligned box hit box of the given size to the entity's bounding-box component. Required (along with a CollidableComponent) for the entity to participate in collision detection.

    • @p Width is the box width in pixels.
    • @p Height is the box height in pixels.
    • @r this object
  • addViewNode (object NodeObj)

    Attaches a visual JavaFX Node to the entity's ViewComponent. This is how an entity becomes visible -- without a view node the entity has a position but renders nothing. The node is positioned relative to the entity and entity transforms apply by default.

    • @p NodeObj is a wrapper exposing the node via .obj (any fx.Rectangle, fx.Circle, fx.ImageView, etc.).
    • @r this object
  • removeViewNode (object NodeObj)

    Removes a visual Node previously added with addViewNode.

    • @p NodeObj is the same wrapper passed to addViewNode.
    • @r this object
  • clearViewNodes ()

    Removes every visual Node from the entity's view.

    • @r this object
  • removeComponentByClass (string ClassName)

    Removes the component of the given Java class type.

    • @p ClassName is the fully qualified component class name.
    • @r A bool, true if removed.
  • hasComponentByClass (string ClassName)

    Returns whether the entity has a component of the given Java class type.

    • @p ClassName is the fully qualified component class name.
    • @r A bool.
  • isColliding (object Other)

    Returns whether the entity is currently colliding with another.

    • @p Other is an Entity wrapper.
    • @r A bool.
  • distance (object Other)

    Returns the Euclidean distance between this entity's anchor point and another's.

    • @p Other is an Entity wrapper.
    • @r A double.
  • getWidth ()

    Returns the entity width (from bounding-box).

    • @r A double.
  • getHeight ()

    Returns the entity height (from bounding-box).

    • @r A double.
  • isActive ()

    Returns whether the entity is active (attached to a GameWorld).

    • @r A bool.
  • removeFromWorld ()

    Removes the entity from its GameWorld.

    • @r this object
  • _optAjo (rawAjo)

  • getPosition ()

    Returns the entity position as an AussomJavaObject around a Point2D. Read components via .invoke("getX") / .invoke("getY").

    • @r An AussomJavaObject around a Point2D.
  • getCenter ()

    Returns the entity center point as an AussomJavaObject around a Point2D. Center is computed from bbox; without a bbox component this returns the entity position.

    • @r An AussomJavaObject around a Point2D.
  • getScaleX ()

    Returns the entity's X scale.

    • @r A double.
  • getScaleY ()

    Returns the entity's Y scale.

    • @r A double.
  • setScaleX (double X)

    Sets the entity's X scale.

    • @p X is the scale factor.
    • @r this object
  • setScaleY (double Y)

    Sets the entity's Y scale.

    • @p Y is the scale factor.
    • @r this object
  • translateTowards (double Tx, double Ty, double Distance)

    Translates the entity toward the given point by the supplied distance.

    • @p Tx is the target X.
    • @p Ty is the target Y.
    • @p Distance is the distance to translate.
    • @r this object
  • rotateToVector (double Vx, double Vy)

    Rotates the entity to face along the given vector.

    • @p Vx is the vector X.
    • @p Vy is the vector Y.
    • @r this object
  • getRightX ()

    Returns the right edge X of the entity's bounding box.

    • @r A double.
  • getBottomY ()

    Returns the bottom edge Y of the entity's bounding box.

    • @r A double.
  • distanceBBox (object Other)

    Returns the bounding-box-relative distance to another entity. Faster and more useful than distance() for collision-radius checks.

    • @p Other is an Entity wrapper.
    • @r A double.
  • setVisible (bool Visible)

    Sets whether the entity is visible.

    • @p Visible is a bool.
    • @r this object
  • isVisible ()

    Returns whether the entity is currently visible.

    • @r A bool.
  • getOpacity ()

    Returns the entity opacity (0.0 - 1.0).

    • @r A double.
  • setOnActive (callback Cb)

    Sets a callback to fire when the entity becomes active (is added to a GameWorld).

    • @p Cb is a callback with no arguments.
    • @r this object
  • setOnNotActive (callback Cb)

    Sets a callback to fire when the entity becomes inactive (is removed from a GameWorld).

    • @p Cb is a callback with no arguments.
    • @r this object
  • getComponent (string ClassName)

    Returns the component instance of the named Java class.

    • @p ClassName is the fully qualified component class name.
    • @r An AussomJavaObject around the Component.
  • getComponentOptional (string ClassName)

    Returns the component instance of the named Java class, or null if not attached.

    • @p ClassName is the fully qualified component class name.
    • @r An AussomJavaObject around the Component, or null.
  • getComponents ()

    Returns the entity's attached components as an AussomJavaObject around a Java List.

    • @r An AussomJavaObject around a List.
  • getViewComponent ()

    Returns the entity's ViewComponent as an AussomJavaObject.

    • @r An AussomJavaObject around the ViewComponent.
  • getBoundingBoxComponent ()

    Returns the entity's BoundingBoxComponent.

    • @r An AussomJavaObject around the BoundingBoxComponent.
  • addHitBox (object HitBoxObj)

    Adds a HitBox (built via BoundingShape factories) to the entity's bounding box.

    • @p HitBoxObj is an AussomJavaObject around a HitBox.
    • @r this object
  • removeHitBox (string Name)

    Removes a HitBox by name.

    • @p Name is the HitBox name.
    • @r this object
  • getPropertyOptional (string Key)

    Returns the optional property value (or null if missing).

    • @p Key is the property name.
    • @r The value or null.
  • setProperty (string Key, Value)

    Sets a property on the entity's PropertyMap.

    • @p Key is the property name.
    • @p Value is the value to store.
    • @r this object
  • getInt (string Key)

    Returns the int property at Key.

    • @p Key is the property name.
    • @r An int.
  • getDouble (string Key)

    Returns the double property at Key.

    • @p Key is the property name.
    • @r A double.
  • getBool (string Key)

    Returns the bool property at Key.

    • @p Key is the property name.
    • @r A bool.
  • getString (string Key)

    Returns the string property at Key.

    • @p Key is the property name.
    • @r A string.
  • getObject (string Key)

    Returns the object property at Key.

    • @p Key is the property name.
    • @r An AussomJavaObject.
  • call (string MethodName, list Args)

    Forwards a method call to one of the entity's components (whichever has a matching method). Wraps Entity.call.

    • @p MethodName is the component method to invoke.
    • @p Args is a list of arguments.
    • @r The method's return value (wrapped).
  • setScaleOrigin (double X, double Y)

    Sets the scale pivot point in 2D space.

    • @p X is the pivot X.
    • @p Y is the pivot Y.
    • @r this object
  • setScaleOrigin3D (double X, double Y, double Z)

    Sets the scale pivot point in 3D space.

    • @p X is the pivot X.
    • @p Y is the pivot Y.
    • @p Z is the pivot Z.
    • @r this object
  • setRotationOrigin (double X, double Y)

    Sets the rotation pivot point in 2D space.

    • @p X is the pivot X.
    • @p Y is the pivot Y.
    • @r this object
  • setRotationOrigin3D (double X, double Y, double Z)

    Sets the rotation pivot point in 3D space.

    • @p X is the pivot X.
    • @p Y is the pivot Y.
    • @p Z is the pivot Z.
    • @r this object
  • getRotationOrigin ()

    Returns the 2D rotation pivot point as a Point2D AJO. Convenience pass-through to the TransformComponent since FXGL's Entity does not delegate this getter directly.

  • getRotationOrigin3D ()

    Returns the 3D rotation pivot point as a Point3D AJO. Convenience pass-through to the TransformComponent since FXGL's Entity does not delegate this getter directly.

  • setLocalAnchor (double X, double Y)

    Sets the local anchor point that getAnchoredPosition and setPosition use as the entity's reference point.

    • @p X is the anchor X.
    • @p Y is the anchor Y.
    • @r this object
  • setLocalAnchorFromCenter ()

    Convenience that sets the local anchor to the entity's geometric center (from the bounding box).

    • @r this object
  • getView ()

    Returns the single primary view Node attached to the entity (the first node of the ViewComponent's children list), or null when no view has been attached.

    • @r An AussomJavaObject around a javafx.scene.Node or null.
  • setView (object NodeObj)

    Replaces every view node with the supplied Node. Useful for "make this entity look like this single sprite" wiring.

    • @p NodeObj is a fx.Node wrapper.
    • @r this object
  • getTypeComponent ()

    Returns the entity's TypeComponent as an AussomJavaObject so callers can bind the value property or compare types polymorphically.

    • @r An AussomJavaObject around the TypeComponent.
  • getWorld ()

    Returns the GameWorld this entity is attached to (or null).

  • isEverUpdated ()

    True when this entity's update tick is enabled.

  • setEverUpdated (bool Value)

    Toggles per-tick updates for this entity.

    • @p Value is a bool: false to skip update calls.
    • @r this object
  • setUpdateEnabled (bool Value)

    Enables or disables the entity's update logic (separate from isActive).

    • @p Value is a bool.
    • @r this object
  • isReusable ()

    True when this entity is reusable (returned to a pool on removal).

  • setReusable (bool Value)

    Marks this entity reusable.

    • @p Value is a bool.
    • @r this object
  • getLocalAnchor ()

    Returns the local anchor offset (Point2D AJO).

  • getAnchoredPosition ()

    Returns the anchored position (no-arg variant; Point2D AJO).

  • setAnchoredPosition (double X, double Y)

    Sets the entity's position so the local anchor lands at the given (x, y).

    • @p X is the target world x.
    • @p Y is the target world y.
    • @r this object
  • getZ ()

    Returns the entity's Z coordinate.

  • setZ (double Z)

    Sets the entity's Z coordinate.

    • @p Z is the new z.
    • @r this object
  • getScaleZ ()

    Returns the entity's Z scale factor.

  • setScaleZ (double ScaleZ)

    Sets the entity's Z scale factor.

    • @p ScaleZ is the new scale.
    • @r this object
  • getPosition3D ()

    Returns the 3D position (Point3D AJO).

  • setPosition3D (double X, double Y, double Z)

    Sets the 3D position from explicit x/y/z.

    • @r this object
  • translate3D (double Dx, double Dy, double Dz)

    Translates the entity by the given delta on each axis.

  • translateX (double Dx)

    Translates the entity along X.

  • translateY (double Dy)

    Translates the entity along Y.

  • translateZ (double Dz)

    Translates the entity along Z.

  • getZIndex ()

    Returns the entity's Z-index (rendering order).

  • isWithin (double X, double Y, double W, double H)

    True when this entity's bounding box overlaps the given rectangle. Java's signature takes a javafx.geometry.Rectangle2D; this wrapper accepts (x, y, w, h) and builds the Rectangle2D AJO on the fly for caller convenience.

  • addComponentListener (object ListenerAjo)

    Registers a ComponentListener AJO. Returns the AJO so the caller can pass it back to removeComponentListener.

    • @p ListenerAjo is an AJO around a ComponentListener.
    • @r The listener AJO.
  • removeComponentListener (object ListenerAjo)

    Removes a previously registered ComponentListener.

    • @p ListenerAjo is the listener AJO returned by add.
    • @r this object
  • getTransformComponent ()

    Returns the entity's TransformComponent AJO (position + rotation + scale).

    • @r An AussomJavaObject around the TransformComponent.
  • copy ()

    Returns a copy of this entity (per the Animatable contract).

  • activeProperty ()

    Returns the active ReadOnlyBooleanProperty AJO.

  • typeProperty ()

    Returns the type ObjectProperty AJO.

  • xProperty ()

    Returns the x DoubleProperty AJO.

  • yProperty ()

    Returns the y DoubleProperty AJO.

  • zProperty ()

    Returns the z DoubleProperty AJO.

  • rotationXProperty ()

    Returns the rotation-X DoubleProperty AJO.

  • rotationYProperty ()

    Returns the rotation-Y DoubleProperty AJO.

  • rotationZProperty ()

    Returns the rotation-Z DoubleProperty AJO (the 2D angle).

  • scaleXProperty ()

    Returns the scaleX DoubleProperty AJO.

  • scaleYProperty ()

    Returns the scaleY DoubleProperty AJO.

  • scaleZProperty ()

    Returns the scaleZ DoubleProperty AJO.

  • widthProperty ()

    Returns the width DoubleProperty AJO.

  • heightProperty ()

    Returns the height DoubleProperty AJO.

  • angleProperty ()

    Returns the angle DoubleProperty AJO (alias for rotation).

  • opacityProperty ()

    Returns the opacity DoubleProperty AJO.