Beep8 logo

Async Documentation

Async Documentation Source Code

Async Methods

beep8.Async.dialog(prompt [,choices]) async

Displays a dialog with the given prompt and choices.

This allows shows a user the prompt and waits for them to select a choice. You can use this for information (with an ‘ok’ response) or for multiple choice answers.

Parameters

  • prompt (string): The text to show.
  • [choices] (string[]): The choices to present to the user. (default: [“OK”)

Returns

  • (*Promise*): The index of the selected item.

beep8.Async.key() async

Waits until the user presses a key and returns it.

Returns

  • (*Promise*): The name of the key that was pressed.

beep8.Async.loadFont(fontImageFile) async

Loads a font for later use in drawing text.

Parameters

  • fontImageFile (string): The URL of the font image file.

Returns

  • (*Promise*): The font ID.

beep8.Async.loadImage(url) async

Loads an image from the given URL.

Parameters

  • url (string): The URL of the image.

Returns

  • (*Promise*): The loaded image.

beep8.Async.loadSound(url) async

Loads a sound file from the given URL.

Parameters

  • url (string): The URL of the sound file.

Returns

  • (*Promise*): The loaded sound.

beep8.Async.pointer() async

Waits until the user clicks/ taps the pointer and returns its position.

Returns

  • (Promise<{x: number, y: number): >} The pointer position.

beep8.Async.readLine([initString] [,maxLen] [,maxWidth]) async

Waits until the user inputs a line of text, then returns it.

Parameters

  • [initString] (string): The initial string presented for the user to edit. (default: “”)
  • [maxLen] (number): The maximum length of the string the user can type. -1 means no limit. (default: -1)
  • [maxWidth] (number): The maximum width of the input line in characters. -1 means no wrapping. (default: -1)

Returns

  • (*Promise*): The input text.

beep8.Async.typewriter(text [,delay]) async

Shows text slowly, character by character, as in a typewriter.

Parameters

  • text (string): The text to print.
  • [delay] (number): The delay between characters in seconds. (default: 0.05)

Returns

  • (*Promise*): Resolves after the text is printed.

beep8.Async.wait(seconds) async

Waits for a given number of seconds.

Parameters

  • seconds (number): The duration to wait.

Returns

  • (*Promise*): Resolves after the specified time.

More Beep8 Docs

Actors Documentation

Async Documentation

Core Functions

Input Documentation

App Intro Documentation

Joystick Documentation

Menu Documentation

Music Documentation

Passcodes Documentation

Public API

Random Numbers Documentation

SFX Documentation

Tilemap Documentation

Utilities Documentation