jetlag2d
    Preparing search index...

    Class PunchBehavior

    PunchBehavior gives an actor a temporary melee hitbox: a second, offset fixture on the actor's own body (see RigidBodyComponent.enablePunch), active for a fixed duration, that moves rigidly with the actor.

    Hierarchy (View Summary)

    Index
    _actor?: Actor<unknown>

    The actor associated with this Behavior

    damage: number

    How much damage does this punch do?

    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.

    • 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

    • React to this actor's punch hitbox touching other: deal damage to a HazardBehavior on other, then end the punch early, so one punch can't hit more than one thing.

      Parameters

      • self: Actor

        This behavior's actor (the puncher)

      • other: Actor

        The actor that touched the punch hitbox

      Returns void

    • Perform a punch: enable a temporary hitbox offset from this actor, for cfg.duration seconds, then disable it automatically.

      Parameters

      • cfg: { duration: number; offset: JLOffset; radius?: number }
        • duration: number

          How long the punch should last, in seconds

        • offset: JLOffset

          The distance between this actor's center and the punch hitbox's center

        • Optionalradius?: number

          The radius of the punch hitbox (default 0.5)

      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