[Dialogue Text Box Lib] Dialogue Demo

0
0
Published 2023-06-12


Dialogue Text Box Library (DTB)

DTB is a code snippet that you can use to implement a dialogue text box to any game in just seconds.
Setting it up goes as follows:

Usage

Call this to initialize all dtb's variables. Takes an optional parameter which defines the maximum number of lines that will be displayed. Defaults to 3.

Call this every update. All logic is contained within dtb.

Call this every time the screen gets drawn. Preferably at the end so the textbox always appears at the top.

Call this to display txt in a textbox. The text is added to a queu so this function can be called multiple times after each other without interfering with the previous text.
Takes an optional callback parameter (function) which is called when this particular piece of text is done displaying.

The actual snippet

Here is the minimized snippet. 1370 characters and 447 tokens:

A readable/editable version can be found in this demo's code.

Feel free to use and customize this code in your own projects! I'd love to see it being used!