Skip to main content

App

Description:

  A record representing an application singleton instance.

frame

Type: Readonly Field.

Description:

  The current passed frame number.

Signature:

const frame: integer

bufferSize

Type: Readonly Field.

Description:

  The size of the main frame buffer texture used for rendering.

Signature:

const bufferSize: Size

visualSize

Type: Readonly Field.

Description:

  The logic visual size of the screen. The visual size only changes when application window size changes. And it won't be affacted by the view buffer scaling factor.

Signature:

const visualSize: Size

devicePixelRatio

Type: Readonly Field.

Description:

  The ratio of the pixel density displayed by the device Can be calculated as the size of the rendering buffer divided by the size of the application window.

Signature:

const devicePixelRatio: number

App.Platform

Type: Enumeration.

Description:

  An enumerated type representing the platform the game engine is running on.

Signature:

enum Platform
"Windows"
"Android"
"macOS"
"iOS"
"Linux"
"Unknown"
end

platform

Type: Readonly Field.

Description:

  The platform the game engine is running on.

Signature:

const platform: Platform

version

Type: Readonly Field.

Description:

  The version string of the game engine. Should be in format of "v0.0.0".

Signature:

const version: string

deps

Type: Readonly Field.

Description:

  The dependencies of the game engine.

Signature:

const deps: string

deltaTime

Type: Readonly Field.

Description:

  The time in seconds since the last frame update.

Signature:

const deltaTime: number

elapsedTime

Type: Readonly Field.

Description:

  The elapsed time since current frame was started, in seconds.

Signature:

const elapsedTime: number

totalTime

Type: Readonly Field.

Description:

  The total time the game engine has been running until last frame ended, in seconds. Should be a contant number when invoked in a same frame for multiple times.

Signature:

const totalTime: number

runningTime

Type: Readonly Field.

Description:

  The total time the game engine has been running until this field being accessed, in seconds. Should be a increasing number when invoked in a same frame for multiple times.

Signature:

const runningTime: number

rand

Type: Readonly Field.

Description:

  A random number generated by a random number engine based on Mersenne Twister algorithm. So that the random number generated by a same seed should be consistent on every platform.

Signature:

const rand: integer

maxFPS

Type: Readonly Field.

Description:

  The maximum valid frames per second the game engine is allowed to run at. The max FPS is being inferred by the device screen max refresh rate.

Signature:

const maxFPS: integer

debugging

Type: Readonly Field.

Description:

  Whether the game engine is running in debug mode.

Signature:

const debugging: boolean

testNames

Type: Readonly Field.

Description:

  An array of test names of engine included C++ tests.

Signature:

const testNames: {string}

locale

Type: Field.

Description:

  The system locale string, in format like: zh-Hans, en.

Signature:

locale: string

themeColor

Type: Field.

Description:

  A theme color for Dora SSR.

Signature:

themeColor: Color

seed

Type: Field.

Description:

  A random number seed.

Signature:

seed: integer

targetFPS

Type: Field.

Description:

  The target frames per second the game engine is supposed to run at. Only works when fpsLimited is set to true.

Signature:

targetFPS: integer

fpsLimited

Type: Field.

Description:

  Whether the game engine is limiting the frames per second. Set fpsLimited to true, will make engine run in a busy loop to track the precise frame time to switch to the next frame. And this behavior can lead to 100% CPU usage. This is usually common practice on Windows PCs for better CPU usage occupation. But it also results in extra heat and power consumption.

Signature:

fpsLimited: boolean

idled

Type: Field.

Description:

  Whether the game engine is currently idled. Set idled to true, will make game logic thread use a sleep time and going idled for next frame to come. Due to the imprecision in sleep time. This idled state may cause game engine over slept for a few frames to lost. idled state can reduce some CPU usage.

Signature:

idled: boolean

winSize

Type: Field.

Description:

  The application window size. May differ from visual size due to the different DPIs of display devices. Set winSize to Size.zero to toggle application window into full screen mode, It is not available to set this property on platform Android and iOS.

Signature:

winSize: Size

winPosition

Type: Field.

Description:

  The application window position. It is not available to set this property on platform Android and iOS.

Signature:

winPosition: Vec2

runTest

Type: Function.

Description:

  A function that runs an specific C++ test included in the engine.

Signature:

runTest: function(self: App, name: string): boolean

Parameters:

ParameterTypeDescription
namestringThe name of the test to run.

Returns:

Return TypeDescription
booleanWhether the test ran successfully.

shutdown

Type: Function.

Description:

  A function that shuts down the game engine. It is not working and acts as a dummy function for platform Android and iOS to follow the specification of how mobile platform applications should operate.

Signature:

shutdown: function(self: App)