Skip to content

Application

Main Application class.

Extends

  • Application

Type parameters

T extends Application = any

Constructors

new Application()

new Application<T>(appConfig?): Application<T>

The config passed in can be a json object, or an AppConfig object.

Parameters

appConfig?: Partial<DillPixelApplicationOptions> & object

Returns

Application<T>

Overrides

PIXIApplication.constructor

See

AppConfig for what can be contained in the passed-in config.

Default

resolution: utils.isMobile.any === false ? 2 : (window.devicePixelRatio > 1 ? 2 : 1);

Default

useNewResizeManager: true

Default

resizeOptions: undefined

Default

resizeDebounce: 0

Default

useSpine: false

Default

showStats: false

Default

showStateDebugMenu: false

Source

src/core/Application.ts:125

Accessors

add

get add(): Add

Returns

Add

Source

src/core/Application.ts:227


addToStage

get addToStage(): <U>(…children) => U[0]

Returns

Function

Adds one or more children to the container.

Multiple items can be added like so: myContainer.addChild(thingOne, thingTwo, thingThree)

Type parameters

U extends DisplayObject[]

Parameters

• …children: U

The DisplayObject(s) to add to the container

Returns

U[0]

  • The first child that was added.

Source

src/core/Application.ts:235


audio

get audio(): IAudioManager

Returns

IAudioManager

Source

src/core/Application.ts:262


copy

get copy(): CopyManager

Returns

CopyManager

Source

src/core/Application.ts:286


defaultState

get defaultState(): undefined | string | typeof State

Returns

undefined | string | typeof State

Source

src/core/Application.ts:306


hitAreaRenderer

get hitAreaRenderer(): HitAreaRenderer

Returns

HitAreaRenderer

Source

src/core/Application.ts:278


htmlTextStyles

get htmlTextStyles(): typeof HTMLTextStyleManager

Returns

typeof HTMLTextStyleManager

Source

src/core/Application.ts:314


keyboard

get keyboard(): KeyboardManager

Returns

KeyboardManager

Source

src/core/Application.ts:254


load

get load(): LoadManager

Returns

LoadManager

Source

src/core/Application.ts:302


make

get make(): typeof Make

Returns

typeof Make

Source

src/core/Application.ts:231


orientationManager

get orientationManager(): OrientationManager

Returns

OrientationManager

Source

src/core/Application.ts:298


physics

get physics(): PhysicsBase

Returns

PhysicsBase

Source

src/core/Application.ts:310


popups

get popups(): PopupManager<T>

Returns

PopupManager<T>

Source

src/core/Application.ts:258


requiredAssets

get requiredAssets(): AssetMapData[]

Override to specify assets that should persist between state loads.

Note: Splash screen assets are loaded before requiredAssets

Returns

AssetMapData[]

Source

src/core/Application.ts:245


resizeOptions

set resizeOptions(value): void

Parameters

value: Partial<ResizeManagerOptions>

Source

src/core/Application.ts:217


resizer

get resizer(): IResizeManager

Returns

IResizeManager

Source

src/core/Application.ts:282


resolutionSuffix

get resolutionSuffix(): string

Returns

string

Source

src/core/Application.ts:223


saveManager

get saveManager(): SaveManager

Returns

SaveManager

Source

src/core/Application.ts:294


screenSize

get screenSize(): Point

Returns

Point

Source

src/core/Application.ts:274


signals

get signals(): typeof Signals

Returns

typeof Signals

Source

src/core/Application.ts:318


size

get size(): Point

Returns

Point

Source

src/core/Application.ts:270


state

get state(): StateManager<T>

Returns

StateManager<T>

Source

src/core/Application.ts:250


voiceover

get voiceover(): IVoiceOverManager

Returns

IVoiceOverManager

Source

src/core/Application.ts:266


webEvents

get webEvents(): WebEventsManager

Returns

WebEventsManager

Source

src/core/Application.ts:290


containerElement

get static containerElement(): undefined | HTMLElement

Returns

undefined | HTMLElement

Source

src/core/Application.ts:198


containerID

get static containerID(): string

Returns

string

Source

src/core/Application.ts:202


instance

get static instance(): Application<any>

gets the current singleton instance

Returns

Application<any>

Source

src/core/Application.ts:209

Methods

addAssetGroup()

addAssetGroup(groupIdOrClass, assets?): void

proxy function for

Parameters

groupIdOrClass: string | typeof State | typeof State

assets?: AssetMapData[]

Returns

void

Source

src/core/Application.ts:354


addPhysics()

addPhysics(type): Promise<PhysicsBase>

Parameters

type: PhysicsEngineType= PhysicsEngineType.MATTER

Returns

Promise<PhysicsBase>

Source

src/core/Application.ts:333


addStats()

addStats(): Promise<void>

Returns

Promise<void>

Source

src/core/Application.ts:322


hasAsset()

hasAsset(pAssetName): boolean

Parameters

pAssetName: string

Returns

boolean

Source

src/core/Application.ts:369


init()

init(): Promise<void>

Initializes all managers and starts the splash screen process.

Returns

Promise<void>

Source

src/core/Application.ts:388


initialize()

initialize(): Promise<void>

Returns

Promise<void>

Source

src/core/Application.ts:373


listFonts()

listFonts(): FontFace[]

Returns

FontFace[]

Source

src/core/Application.ts:445


loadDocumentFonts()

loadDocumentFonts(): Promise<void>

Returns

Promise<void>

Source

src/core/Application.ts:437


loadHTMLTextStyles()

loadHTMLTextStyles(): Promise<void>

Preload any custom font styles to be used later on with html text currently not sure if there’s a better way to do this…

Returns

Promise<void>

See

Async

Example

// in your Application.ts:
import {loadAndAddHTMLTextStyle} from 'dill-pixel';
// override loadHTMLTextStyles and do:
await loadAndAddHTMLTextStyle('style1', FONT_FAMILY_NAME_1, { fontSize: 16, lineHeight: 19, fill: 'white' }, [{url:'assets/fonts/{fontFile1}.woff2', weight: 'normal'}, {url:'assets/fonts/{fontFile2}.woff2', weight: 'bold'}]);
// then later on, from anywhere in your app, you can do:
import {getHTMLTextStyle} from 'dill-pixel';
this.add.htmlText( 'This is some text', getHTMLTextStyle('style1'), ...);

Source

src/core/Application.ts:471


playVO()

playVO(key, mode?, callback?): void

Plays a voiceover. Override to e.g. add clauses to playback

Parameters

key: string | (string | number)[]

mode?: PlayMode | Callback | Partial<IPlayOptions>

callback?: Callback

Returns

void

Source

src/core/Application.ts:482


createContainer()

static createContainer(pId): HTMLDivElement

Creates a container element with the given id and appends it to the DOM.

Parameters

pId: string

Returns

HTMLDivElement

Source

src/core/Application.ts:96


getInstance()

static getInstance<T>(): T

Creates a new instance of the Application class and returns it.

Type parameters

T extends Application<any> = Application<any>

Returns

T

Source

src/core/Application.ts:106