Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: TransformComponent

[21:7] extends: Component

Wraps FXGL's TransformComponent (com.almasb.fxgl.entity.components.TransformComponent), the core component that holds an entity's position, rotation, scale, and pivot origins in both 2D and 3D space. Reachable through Entity.getComponent("com.almasb.fxgl.entity.components.TransformComponent") or as the raw AJO behind Entity.setX / Entity.setRotation / etc. Exposes value get/set pairs, the underlying JavaFX DoubleProperty handles for binding, and the translate / rotateBy / lookAt convenience methods.

Methods

  • TransformComponent (double X = 0.0, double Y = 0.0, double Angle = 0.0, double ScaleX = 1.0, double ScaleY = 1.0)

    Creates a TransformComponent at (X, Y) with the given angle and scale.

  • adopt (object Ajo)

    Wraps an existing TransformComponent AussomJavaObject.

  • getX ()

  • setX (double X)

  • getY ()

  • setY (double Y)

  • getZ ()

  • setZ (double Z)

  • setPosition (double X, double Y)

    Sets (X, Y) in one call.

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

    Sets (X, Y, Z) in one call.

  • getPosition ()

    Returns the position as a Point2D AJO.

  • getPosition3D ()

    Returns the 3D position as a Point3D AJO.

  • getAngle ()

  • setAngle (double A)

  • getRotationX ()

  • setRotationX (double A)

  • getRotationY ()

  • setRotationY (double A)

  • getRotationZ ()

  • setRotationZ (double A)

  • rotateBy (double Degrees)

    Rotates around the Z axis by the supplied delta degrees.

  • getScaleX ()

  • setScaleX (double S)

  • getScaleY ()

  • setScaleY (double S)

  • getScaleZ ()

  • setScaleZ (double S)

  • getScaleOrigin ()

  • setScaleOrigin (double X, double Y)

  • getRotationOrigin ()

  • setRotationOrigin (double X, double Y)

  • translateX (double X)

  • translateY (double Y)

  • translateZ (double Z)

  • translate (double DX, double DY)

  • xProperty ()

  • yProperty ()

  • zProperty ()

  • angleProperty ()

  • scaleXProperty ()

  • scaleYProperty ()

  • scaleZProperty ()

  • rotationXProperty ()

  • rotationYProperty ()

  • rotationZProperty ()

  • getScaleOrigin3D ()

    Returns the 3D scale-origin Point3D AJO.

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

    Sets the 3D scale-origin from (X, Y, Z).

  • getRotationOrigin3D ()

    Returns the 3D rotation-origin Point3D AJO.

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

    Sets the 3D rotation-origin from (X, Y, Z).

  • getLocalAnchor ()

    Returns the local-anchor Point2D AJO (defaults to (0, 0)).

  • setLocalAnchor (double X, double Y)

    Sets the local anchor from (X, Y).

  • getAnchoredPosition ()

    Returns the anchored position (position - localAnchor).

  • setAnchoredPosition (double X, double Y)

    Sets the anchored position from (X, Y); the engine adds the local anchor back.

  • getDirection3D ()

    Returns the forward direction Point3D AJO.

  • getUp3D ()

    Returns the local up Point3D AJO.

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

    Sets the forward direction vector from (X, Y, Z).

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

    Orients the transform to look at the world-space point (X, Y, Z).

  • lookUpBy (double Degrees)

    Pitches the look direction up by Degrees.

  • lookDownBy (double Degrees)

    Pitches the look direction down by Degrees.

  • lookLeftBy (double Degrees)

    Yaws the look direction left by Degrees.

  • lookRightBy (double Degrees)

    Yaws the look direction right by Degrees.

  • bindToLookAt3D (object OtherTC)

    Binds this transform's look-at to follow Other's 3D position.

  • unbindToLookAt3D ()

    Removes the bindToLookAt3D binding installed earlier.

  • bindTranslation (object OtherTC)

    Binds this transform's translation to track Other's translation.

  • translate3D (double DX, double DY, double DZ)

    Translates by (DX, DY, DZ).

  • translateTowards (double TargetX, double TargetY, double Distance)

    Translates toward a target 2D point by Distance pixels.

  • moveForward (double Distance)

    Moves forward by Distance in the current look direction.

  • moveBack (double Distance)

    Moves backward by Distance in the current look direction.

  • moveLeft (double Distance)

    Strafes left by Distance.

  • moveRight (double Distance)

    Strafes right by Distance.

  • moveForwardXZ (double Distance)

    Moves forward by Distance projected onto the X-Z plane.

  • moveBackXZ (double Distance)

    Moves backward by Distance projected onto the X-Z plane.

  • distance (object OtherTC)

    Returns the 2D distance to Other transform.

  • distance3D (object OtherTC)

    Returns the 3D distance to Other transform.

  • rotateToVector (double X, double Y)

    Rotates the transform so it points toward the supplied 2D vector.

  • positionOriginXProperty ()

  • positionOriginYProperty ()

  • positionOriginZProperty ()

  • scaleOriginXProperty ()

  • scaleOriginYProperty ()

  • scaleOriginZProperty ()

  • rotationOriginXProperty ()

  • rotationOriginYProperty ()

  • rotationOriginZProperty ()

  • write (object BundleObj)

    Writes the transform's state into a Bundle.

  • read (object BundleObj)

    Restores the transform's state from a Bundle.