Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: ProjectileComponent

[17:7] extends: Component

Wraps FXGL's ProjectileComponent (com.almasb.fxgl.dsl.components.ProjectileComponent), a DSL Component that translates the entity each tick along a Point2D direction at a given speed. Automatically rotates the entity to face the direction of motion (0 degrees assumed to face right).

Methods

  • ProjectileComponent (double Dx = 1.0, double Dy = 0.0, double Speed = 1.0)

    Creates a new ProjectileComponent. Pass (Dx, Dy, Speed) to set the initial direction vector and speed; with no arguments uses (1.0, 0.0) facing right at 1.0.

    • @p Dx is the X component of the initial direction.
    • @p Dy is the Y component of the initial direction.
    • @p Speed is the initial speed in pixels per second.
  • adopt (object Ajo)

    Wraps an existing ProjectileComponent AussomJavaObject.

  • getVelocity ()

    Returns the velocity Point2D AJO (direction.normalize() * speed).

  • getDirection ()

    Returns the direction Point2D AJO (velocity.normalize()).

  • setDirection (double Dx, double Dy)

    Sets the direction of motion. The direction vector is normalized internally and scaled by the current speed.

    • @p Dx is the X component of the direction.
    • @p Dy is the Y component of the direction.
    • @r this object
  • getSpeed ()

    Returns the current speed (double).

  • setSpeed (double Speed)

    Sets the speed.

    • @p Speed is the speed in pixels per second.
    • @r this object
  • speedProperty ()

    Returns the DoubleProperty for speed (binding-friendly).

  • allowRotation (bool AllowRotation)

    Enables or disables auto-rotation toward the direction of travel.

    • @p AllowRotation true to enable rotation.
    • @r this object