[title: "Text Class"] ← Back to index

A versatile text rendering system with retro font support and advanced text effects.

[heading: "Description"]

Text provides advanced text rendering capabilities using retro pixel fonts. It supports typewriter effects, scrolling text, word wrapping, and multi-line text with various formatting options.

[heading: "Key Features"] [list] * Retro pixel font rendering * Typewriter and scrolling text effects * Automatic word wrapping * Multi-line text support * Custom font configurations * Text alignment and anchoring * Tinting support [/list] [heading: "Constructor"] [table header] [ Parameter | Type | Description ] [ x | Number | X position ] [ y | Number | Y position ] [ text | String | Initial text content ] [ config | Object | Font configuration (optional) ] [ parent | Phaser.Group | Parent group to attach to (optional) ] [/table] [heading: "Methods"] [table header] [ Method | Parameters | Description ] [ write | (text, max) | Sets text content immediately, optionally truncates ] [ typewrite | (text, callback) | Types text character by character ] [ scrollwrite | (text, visibleLength, scrollSpeed, separation) | Creates scrolling text effect ] [ stopScrolling | () | Stops any active scrolling animation ] [ isScrolling | () | Returns whether text is currently scrolling ] [ wrap | (maxWidth, lineSpacing) | Wraps text to fit width ] [ wrapPreserveNewlines | (maxWidth, lineSpacing) | Wraps text while preserving existing newlines ] [ getWrappedText | (maxWidth) | Returns wrapped text without modifying display ] [/table] [heading: "Properties"] [table header] [ Property | Type | Description ] [ config | Object | Text configuration settings ] [ texture | Phaser.RetroFont | Retro font texture instance ] [ timer | Phaser.Timer | Timer for text animations ] [ typewriterInterval | Number | Delay between characters in typewriter effect ] [ tint | Number | Text color (hex) ] [ anchor | Object | Text anchor point (x, y) ] [/table] [heading: "Configuration Options"] [table header] [ Option | Type | Default | Description ] [ font | String | "font_tiny" | Font key from FONTS constant ] [ fontMap | String | " ABCDEFGHIJKLMNOPQRSTUVWXYZ.,:!¡?¿h+-×*()[]/\\0123456789_'\"`•<>=%" | Character mapping ] [ fontWidth | Number | 4 | Character width in pixels ] [ fontHeight | Number | 6 | Character height in pixels ] [ typewriter | Boolean | false | Enable typewriter effect ] [ typewriterInterval | Number | 100 | Milliseconds between characters ] [ tint | Number | 0xffffff | Text color ] [/table] [heading: "Available Fonts"] [table header] [ Font Key | Description ] [ default | Standard pixel font ] [ tiny | Small pixel font (alias for default) ] [ shaded | Font with drop shadow effect ] [ stroke | Outlined font for better visibility ] [ number | Optimized for numerical display ] [ combo | Large font for combo display ] [/table] [heading: "Example Usage"] [codeblock javascript] // Basic text const text = new Text(10, 10, "Hello World", FONTS.default); // Typewriter effect text.typewrite("This appears letter by letter", () => { console.log("Finished typing!"); }); // Scrolling text const scroller = text.scrollwrite("This is a very long text that scrolls", 10, 200); // Word wrapping text.wrap(100); // Change color text.tint = 0xff0000; [/codeblock] [footer: "© Retora 2026"]