PlatformerObjectRuntimeBehavior represents a behavior allowing objects to be considered as a platform by objects having PlatformerObject Behavior.

Hierarchy (view full)

Constructors

Properties

name: string

The object owning the behavior

type: string
epsilon: number = ...

A very small value compare to 1 pixel, yet very huge compare to rounding errors.

Methods

  • Check if the Platformer Object is "going down", either because it's in the falling state or because it's jumping but reached the jump peak and is now going down (because the jump speed can't compensate anymore the falling speed).

    If you want to check if the object is falling outside of a jump (or because the jump is entirely finished and there is no jump speed applied to the object anymore), consider using isFallingWithoutJumping.

    Returns boolean

    Returns true if it is "going down" and false if not.

  • Check if the Platformer Object is moving.

    When walking or climbing on a ladder, a speed of less than one pixel per frame won't be detected.

    Returns boolean

    Returns true if it is moving and false if not.

    Deprecated

    use isMovingEvenALittle instead

  • Reimplement this to do extra work when the behavior is created (i.e: an object using it was created), after the object is fully initialized (so you can use this.owner without risk).

    Returns void

  • This method is called when the owner of the behavior is being removed from the scene and is about to be destroyed/reused later or when the behavior is removed from an object (can happen in case of hot-reloading only. Otherwise, behaviors are just de-activated, not removed. See onDeActivate).

    Returns void

  • Set the maximum falling speed of the Platformer Object.

    Parameters

    • maxFallingSpeed: number

      The maximum falling speed.

    • tryToPreserveAirSpeed: boolean = false

      If true and if jumping, tune the current jump speed to preserve the overall speed in the air.

    Returns void

  • Called when the behavior must be updated using the specified behaviorData. This is the case during hot-reload, and is only called if the behavior was modified.

    Parameters

    • oldBehaviorData: any

      The previous data for the behavior.

    • newBehaviorData: any

      The new data for the behavior.

    Returns boolean

    true if the behavior was updated, false if it could not (i.e: hot-reload is not supported).

    See

    gdjs.RuntimeBehavior#onObjectHotReloaded

  • Should return false if the behavior does not need any lifecycle function to be called. Default, hidden, "capability" behaviors set it to false. This avoids useless calls to empty lifecycle functions, which would waste CPU time (and have a sizeable impact for example when lots of static instances are living in the scene).

    Returns boolean