Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: ProjectileWithAccelerationComponent

[19:7] extends: Component

Wraps FXGL's ProjectileWithAccelerationComponent (com.almasb.fxgl.dsl.components.ProjectileWithAccelerationComponent), a DSL Component that translates the entity each tick along a Point2D direction with an additional acceleration vector applied per tick. Automatically rotates the entity to face the direction of motion. Does not extend FXGL's ProjectileComponent.

Methods

  • ProjectileWithAccelerationComponent (double Dx = 1.0, double Dy = 0.0, double Speed = 1.0, double Ax = 0.0, double Ay = 0.0)

    Creates a new component with the given initial direction, speed, and optional acceleration. Defaults to (1,0) direction at speed 1.0 and zero acceleration when no arguments are passed.

    • @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.
    • @p Ax is the X component of the acceleration vector.
    • @p Ay is the Y component of the acceleration vector.
  • adopt (object Ajo)

    Wraps an existing component AussomJavaObject.

  • getVelocity ()

    Returns the velocity Point2D AJO.

  • getDirection ()

    Returns the direction Point2D AJO.

  • setDirection (double Dx, double Dy)

    Sets the direction of motion.

    • @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
  • getAcceleration ()

    Returns the acceleration Point2D AJO.

  • setAcceleration (double Ax, double Ay)

    Sets the acceleration vector.

    • @p Ax is the X component.
    • @p Ay is the Y component.
    • @r this object
  • allowRotation (bool AllowRotation)

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

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