jetlag2d
    Preparing search index...

    Class SolidBehavior

    SolidBehavior is for things that other bodies bounce off of, rather than pass through. These tend to be pretty customizable. They can be moved, and used in all sorts of other ways.

    Hierarchy (View Summary)

    Index
    • Construct a SolidBehavior

      Parameters

      • cfg: {
            absorbsProjectiles?: boolean;
            jumpReEnableSides?: DIRECTION[];
            onContact?: (self: Actor, other: Actor) => void;
            team?: number;
        } = {}
        • OptionalabsorbsProjectiles?: boolean

          Should a ThrowableBehavior that touches this disappear? (default true)

        • OptionaljumpReEnableSides?: DIRECTION[]

          Which sides "count" for letting a jumping actor jump again (default: all)

        • OptionalonContact?: (self: Actor, other: Actor) => void

          Code to run when any actor collides with this

        • Optionalteam?: number

          The team this actor belongs to (default 0)

      Returns SolidBehavior

    _actor?: Actor<unknown>

    The actor associated with this Behavior

    absorbsProjectiles: boolean

    Should a ThrowableBehavior that touches this disappear (default true)? Set false to let projectiles bounce/pass off this instead of being destroyed -- Box2D's own physics does the actual bouncing once the projectile isn't removed, so this is the only decision this makes.

    jumpReEnableSides: DIRECTION[]

    Which of this Solid's sides "count" as ground, letting a jumping actor jump again

    onContact?: (self: Actor, other: Actor) => void

    Code to run when any other actor touches this

    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

    • 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