jetlag2d
    Preparing search index...

    Class TextSprite

    TextSprite describes any text object that can be drawn to the screen. The text that is displayed can be controlled by a callback, so that it can change over time.

    Index
    • Build some text that can be rendered

      Parameters

      • cfg: {
            center: boolean;
            color: string;
            face: string;
            lineHeight?: number;
            offset?: JLOffset;
            size: number;
            strokeColor?: string;
            strokeWidth?: number;
            wrapWidth?: number;
            z?: 0 | 1 | 2 | 4 | -4 | 3 | -3 | -2 | -1;
        }
        • center: boolean

          Should the text be centered at the rigid body's (cx,cy) (true) or is the rigid body's (cx,cy) top-left (false)?

        • color: string

          Color for the text (should be an RGB string code, like #aa4433)

        • face: string

          Name of the font to use

        • OptionallineHeight?: number

          Line height, as a multiple of font size (optional, default 1.25)

        • Optionaloffset?: JLOffset

          An offset between the component's center and its RigidBody's center (optional)

        • size: number

          Font size

        • OptionalstrokeColor?: string

          The color of the text outline (optional)

        • OptionalstrokeWidth?: number

          The width of the text outline (optional)

        • OptionalwrapWidth?: number

          If provided, the text word-wraps onto multiple lines so that it stays within this many meters of width (optional). Lines are centered if center is true, and left-aligned otherwise.

        • Optionalz?: 0 | 1 | 2 | 4 | -4 | 3 | -3 | -2 | -1

          An optional z index in the range [-4,4] (default 0)

      • producer: string | ((a: Actor) => string)

        A function that creates the text to display, or a String

      Returns TextSprite

    actor?: Actor<unknown>

    The Actor to which this TextSprite is attached

    center: boolean

    Should the text be centered at X,Y (true) or is (X,Y) top-left (false)

    height: number = 0

    Height of the text (computed)

    offset: JLOffset

    An offset between the TextSprite's center and the RigidBody's center

    producer: string | ((a: Actor) => string)

    A function that creates the text to display, or a String

    text: Text

    The low-level text object that we pass to the Renderer

    width: number = 0

    Width of the text (computed)

    z: -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4

    Z index of the image

    • get wrapWidth(): number | undefined

      Width, in meters, at which the text word-wraps onto multiple lines. If undefined, the text never wraps. When wrapping, lines are centered if center is true, and left-aligned otherwise.

      Returns number | undefined

    • set wrapWidth(v: number | undefined): void

      Width, in meters, at which the text word-wraps (undefined = no wrap)

      Parameters

      • v: number | undefined

      Returns void