App class abstract App

The base App class. Extend from this class to create a Bullseye2D application.

An App provides the main structure for a game, handling the game loop, input, rendering, audio, and resource management.

To create a game, you typically:

  1. Extend this App class.
  2. Override lifecycle methods like onCreate, onUpdate, and onRender.
  3. Instantiate your custom App class in your main() function.
class MyGame extends App {
  @override
  void onCreate() {
    // Initialize resources here
    log('Game created!');
  }

  @override
  void onUpdate() {
    // Game logic updates here
  }

  @override
  void onRender() {
    // Rendering code here
    gfx.clear(0.1, 0.2, 0.3); // Clear screen with a color
  }
}

void main() {
  MyGame();
}

Constructors

App([AppConfig? config])
Creates a new App instance.

Properties

accel Accelerometer
Provides access to the device's accelerometer data.
latefinal
audio Audio
Manages audio playback for sounds and music.
latefinal
canvas HTMLCanvasElement
The HTML canvas element on which the game is rendered.
latefinal
gamepad Gamepad
Handles gamepad input from connected controllers.
latefinal
gfx Graphics
The main graphics interface for rendering 2D primitives, textures, and text.
latefinal
hashCode int
The hash code for this object.
no setterinherited
height int
The current height of the game canvas in pixels.
getter/setter pair
keyboard Keyboard
Manages keyboard input.
latefinal
loader Loader
Manages the loading of game assets.
latefinal
mouse Mouse
Manages mouse and touch input.
latefinal
resources ResourceManager
Manages loading and caching of game resources like textures, fonts, and sounds.
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
updateRate double
Gets the target update rate of the game loop in updates per second (Hz).
getter/setter pair
width int
The current width of the game canvas in pixels.
getter/setter pair

Methods

hideMouse() → void
Hides the mouse cursor.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onCreate() → void
Called once when the application is created and initialized.
onLoading() bool
Called repeatedly while game assets are loading.
onRender() → void
Called repeatedly by the game loop to render the game scene.
onResize(int width, int height) → void
This is called as soon as the dimension of the canvas changes. Bullseye2D provides a default implementation that updates the projection matrix, but you are free to overwrite it, and provide your custom implementation.
onResume() → void
Called when the application is resumed after being suspended.
onSuspend() → void
Called when the application is suspended.
onUpdate() → void
Called repeatedly by the game loop to update game logic.
showMouse([Images? images, int frame = 0]) → void
Shows the mouse cursor, optionally customizing its appearance with an image.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

instance App
getter/setter pair