jetlag2d
    Preparing search index...

    Class JumpBehavior

    JumpBehavior grants an actor the ability to jump. Jumping is not just "moving upward", because:

    • It gets a special animation state
    • It can be capped (double-jump before touching ground)
    • It is a special state for causing damage to other actors

    Hierarchy (View Summary)

    Index
    • Construct a JumpBehavior

      Parameters

      • cfg: { allowMultiJump?: boolean; numJumpsAllowed?: number; team?: number } = {}
        • OptionalallowMultiJump?: boolean

          True if the actor can jump infinitely often while airborne

        • OptionalnumJumpsAllowed?: number

          Use 2 to enable double-jumps, etc.

        • Optionalteam?: number

          The team this actor belongs to (default 0)

      Returns JumpBehavior

    _actor?: Actor<unknown>

    The actor associated with this Behavior

    allowMultiJump: boolean

    Indicate that the actor can jump infinitely often while in the air

    team: number = 0

    Which "team" this Behavior belongs to. A team is just a number, and for the most part it's only when user code consults teams that teams have meaning. The only exception is that HazardBehavior uses team to prevent team attack damage.

    • get numJumpsAllowed(): number

      How many jumps the actor gets before it needs to touch the ground again (always at least 1). This can change after the actor is built, e.g., when the actor picks up a power-up that grants a double jump.

      Returns number

    • set numJumpsAllowed(n: number): void

      Set how many jumps the actor gets before touching the ground (values below 1 become 1)

      Parameters

      • n: number

      Returns void

    • Turn off physical collisions for actor. Used by Behaviors that are only ever passed through, not physically collided with, like coins.

      Parameters

      • actor: Actor<unknown> | undefined

        The actor being attached (may be undefined, if this Behavior is being detached)

      Returns void

    • Make the actor jump, unless it is in the air and out of jumps, or it is crawling

      Parameters

      • x: number
      • y: number

      Returns void

    • If actor's body isn't dynamic, warn and upgrade it to dynamic. Used by every Behavior whose whole point requires a dynamic body (e.g. setVelocity/forces actually doing something).

      Parameters

      • actor: Actor<unknown> | undefined

        The actor being attached (may be undefined, if this Behavior is being detached)

      • behaviorName: string

        The name to use in the warning message

      Returns void

    • Called (typically by a SolidBehavior this actor lands on) to indicate the actor is back on solid ground and can jump again.

      Returns void