simple-visual-novel
    Preparing search index...

    Class VNEngine

    Main engine class for running visual novels.

    The VNEngine orchestrates the visual novel experience by managing the script, game state, rendering, and event system. It provides methods for scene navigation, variable management, and event handling.

    When created in a browser environment, it automatically instantiates a DOMRenderer to display the visual novel.

    VNEngine

    const script = new Script();
    // ... add scenes to script ...

    const engine = new VNEngine({
    script,
    container: "#game-container",
    startScene: "intro",
    renderer: {
    assetsDirectory: "assets",
    typewriterSpeed: 50
    }
    });

    // Listen for events
    engine.on("sceneChange", (event) => {
    console.log("Scene changed to:", event.data.sceneId);
    });

    // Use game variables
    engine.setVariable("playerName", "Alex");
    Index

    Constructors

    Accessors

    • get allVariables(): Record<string, any>

      Gets all game variables.

      Returns Record<string, any>

    Methods

    • Gets a game variable.

      Parameters

      • key: string

        Variable name

      Returns any

      The variable value, or undefined if not set

    • Jumps to a specific scene by ID.

      Parameters

      • sceneId: string

        The scene ID to jump to

      Returns void

      If the scene is not found

    • Moves to the next scene in the script order.

      Returns boolean

      True if moved to next scene, false if no next scene exists

    • Sets a game variable.

      Parameters

      • key: string

        Variable name

      • value: any

        Variable value

      Returns void