simple-visual-novel
    Preparing search index...

    Class Character

    Represents a character in the visual novel.

    Characters are the primary actors in a visual novel. They can speak dialogue, be shown or hidden on screen, and have their appearance changed dynamically.

    Characters must be added to a scene before they can perform actions like speaking dialogue or being shown/hidden.

    Character

    // Create a character with a sprite
    const alice = new Character("Alice", "alice.png");

    // Add to a scene and use
    scene.add(alice, { position: "left" });
    alice.say("Hello!", { effect: "typewriter" });
    alice.image = "alice-happy.png"; // Change expression
    alice.hide();
    Index

    Constructors

    Accessors

    Methods

    Constructors

    • Creates a new Character instance.

      Parameters

      • name: string

        The character's name

      • Optionalimage: string

        Optional image/sprite URL for the character

      Returns Character

    Accessors

    • set currentScene(scene: Scene | null): void
      Internal

      Sets the current scene for this character.

      This is called automatically when a character is added to a scene via scene.add(). It enables the character to queue actions in that scene.

      Parameters

      • scene: Scene | null

        The scene to associate with this character, or null to disassociate

      Returns void

    • get image(): string | undefined

      Gets the character's image/sprite URL.

      Returns string | undefined

      The character's image URL, if set

    • set image(value: string | undefined): void

      Sets the character's image/sprite URL. If the character is in a scene, this queues an action to update the displayed image.

      Parameters

      • value: string | undefined

        The image URL to set

      Returns void

    • get name(): string

      Gets the character's name.

      Returns string

      The character's name

    • get size(): Size | undefined

      Gets the character's size.

      Returns Size | undefined

      The character's size, if set

    • set size(value: Size | undefined): void

      Sets the character's size.

      Parameters

      • value: Size | undefined

        The size to set

      Returns void

    Methods

    • Hides the character in the current scene.

      Returns void

      If character is not added to a scene

    • Queues dialogue for the character to speak.

      Parameters

      • text: string

        The dialogue text

      • Optionaloptions: DialogueOptions

        Optional dialogue options

        Options for dialogue display.

        • Optionaleffect?: "fade" | "typewriter"

          Text effect to apply

      Returns void

      If character is not added to a scene

    • Shows the character in the current scene.

      Parameters

      • Optionaloptions: { position?: Position; size?: Size }

        Optional show options

        • Optionalposition?: Position

          Override position for this show action

        • Optionalsize?: Size

          Override size for this show action

      Returns void

      If character is not added to a scene