Skip to content

Add visible character control to Text and BitmapText #1411

@obiot

Description

@obiot

Summary

Add properties to control how many characters of a text renderable are visible, enabling typewriter effects, progressive text reveal, and dialogue systems.

Proposed API

// character count — show only the first N characters (-1 = all)
text.visibleCharacters = 5; // shows "Hello" from "Hello world!"
text.visibleCharacters = -1; // shows all (default)

// ratio — percentage of text visible (0.0 to 1.0)
text.visibleRatio = 0.5; // shows first 50% of characters
text.visibleRatio = 1.0; // shows all (default)

Setting visibleRatio auto-syncs visibleCharacters based on total character count, and vice versa.

Typewriter effect with Tween

const dialog = new BitmapText(10, 10, {
    font: "PressStart2P",
    text: "The princess is in another castle..."
});
dialog.visibleRatio = 0;

// animate text reveal over 2 seconds
new Tween(dialog).to({ visibleRatio: 1.0 }, 2000).start();

Implementation Notes

  • BitmapText: skip glyph rendering past visibleCharacters count in the draw loop
  • Text: substring the text before canvas fillText/strokeText calls
  • Both properties should work together — setting one updates the other
  • visibleCharacters = -1 and visibleRatio = 1.0 should be the defaults (full text visible, zero overhead)
  • Should work with multi-line text (count includes characters across all lines, excluding line breaks or including them — TBD)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions