App class is the root instance of any ceramic app.

Events

@:dox(show)ready():Void

Fired when the app is ready and the game logic can be started.

@:dox(show)update(delta:Float):Void

Fired as many times as there are frames per seconds. It is in sync with screen FPS but used for everything that needs to get updated depending on time (ceramic.Timer relies on it). Use this event to update your contents before they get drawn again.

Parameters:

delta

The elapsed delta time since last frame

@:dox(show)preUpdate(delta:Float):Void

Fired right before update event and can be used when you want to run garantee your code will be run before regular update event.

Parameters:

delta

The elapsed delta time since last frame

@:dox(show)postUpdate(delta:Float):Void

Fired right after update event and can be used when you want to run garantee your code will be run after regular update event.

Parameters:

delta

The elapsed delta time since last frame

@:dox(show)defaultAssetsLoad(assets:Assets):Void

Fired right before default assets are being loaded.

Parameters:

assets

The Assets instance used to load default assets. If you add custom assets to this instance, they will be loaded as well.

@:dox(show)criticalError(error:Dynamic, stack:Array<StackItem>):Void

Fired when the app hits an critical (uncaught) error. Can be used to perform custom crash reporting. If this even is handled, app exit should be performed by the event handler.

Parameters:

error

The error

stack

The stack trace of the error

@:dox(show)beginEnterBackground():Void

Fired when the app will enter background state.

@:dox(show)finishEnterBackground():Void

Fired when the app did finish entering background state.

@:dox(show)beginEnterForeground():Void

Fired when the app will enter foreground state.

@:dox(show)finishEnterForeground():Void

Fired when the app did finish entering foreground state.

@:dox(show)beginSortVisuals():Void

Fired right before sorting all visuals. Visual are sorted at each frame depending on their properties: depth, texture, blending, shader...

@:dox(show)finishSortVisuals():Void

Fired right after all visuals have been sort.

@:dox(show)beginDraw():Void

Fired right before drawing phase of visuals.

@:dox(show)finishDraw():Void

Fired right after drawing phase of visuals.

@:dox(show)lowMemory():Void

Fired if the app is running low on memory. (not be implemented by all platforms/targets).

@:dox(show)terminate():Void

Fired when the app terminates.

Static variables

staticread onlyapp:App

Shared App instance singleton.

Variables

@:value(false)read onlyinUpdate:Bool = false

true if the app is currently running its update phase.

read onlycomputedFps:Int

Computed fps of the app. Read only. Value is automatically computed from last second of frame updates.

@:value(0)read onlyframe:Int = 0

Current frame number

read onlydelta:Float

Current frame delta time (never above settings.maxDelta)

read onlyrealDelta:Float

Current frame real delta time (the actual elapsed time since last frame update)

read onlybackend:Backend

Backend instance

read onlyscreen:Screen

Screen instance

read onlyaudio:Audio

Audio instance

read onlysettings:Settings

App settings

read onlysystems:Systems

Systems are objects to structure app work/phases and update cycle

@:value(new Logger())read onlylogger:Logger = new Logger()

Logger. Used by log shortcut

@:value([])read onlyvisuals:Array<Visual> = []

Visuals (ordered) Active list of visuals being managed by ceramic. This list is ordered and updated at every frame. In between, it could contain destroyed visuals as they are removed only at the end of the frame for performance reasons.

@:value([])read onlypendingVisuals:Array<Visual> = []

Pending visuals: visuals that have been created this frame but were not added to the visual list yet

@:value([])read onlydestroyedVisuals:Array<Visual> = []

Pending destroyed visuals: visuals that have been destroyed this frame but were not removed to the visual list yet

@:value([])read onlygroups:Array<Group<Entity>> = []

All groups of entities in this app

read onlyinput:Input

Shared instance of Input

@:value([])read onlyrenderTextures:Array<RenderTexture> = []

All active render textures in this app

read onlyassets:Assets

App level assets. Used to load default assets (font, texture, shader) required to make ceramic work properly.

@:value(null)read onlydefaultTexturedShader:Shader = null

Default textured shader. This is the shader used for any visual (quad or mesh) that don't have a custom shader assigned.

@:value(null)read onlydefaultWhiteTexture:Texture = null

Default white texture. When a quad or mesh doesn't have a texture assigned, it will use the default white texture instead to render as plain flat coloured object. This means that the same default shader is used and everything can be batched together (textured & non-textured in the same batch).

@:value(null)read onlydefaultFont:BitmapFont = null

Default font used by Text instances.

@:value(null)projectDir:String = null

Project directory. May be null depending on the platform.

@:value(null)read onlypersistent:PersistentData = null

App level persistent data. This is a simple key-value store ready to be used. Don't forget to call persistent.save() to apply changes permanently.

@:value(null)read onlytextInput:TextInput = null

Shared text input manager. Usually not used directly as is. You might want to use EditText component instead.

@:value(new Map())converters:Map<String, ConvertField<Dynamic, Dynamic>> = new Map()

Converters are used to transform field data in Fragment instances. This map is matching a type (as string, like "Array<Float>") with an instance of a ConvertField subclass.

@:value(new Timelines())timelines:Timelines = new Timelines()

All active timelines in this app.

@:value(null)arcade:ArcadeSystem = null

Available with arcade plugin

Shared arcade system. (arcade plugin)

@:value(SceneSystem.shared)@lazyscenes:SceneSystem = SceneSystem.shared

Shared scene system.

@:value(null)nape:NapeSystem = null

Available with nape plugin

Shared nape system. (nape plugin)

Methods

inlineonceImmediate(owner:Entity, handleImmediate:() ‑> Void):Void

inlineonceImmediate(handleImmediate:() ‑> Void):Void

Schedule immediate callback that is garanteed to be executed before the next time frame (before elements are drawn onto screen)

Parameters:

owner

Owner of this callback, allowing to cancel callback if owner is destroyed

handleImmediate

The callback to execute

@:value({ defer : true })inlineoncePostFlushImmediate(owner:Entity, handlePostFlushImmediate:() ‑> Void, defer:Bool = true):Void

@:value({ defer : true })inlineoncePostFlushImmediate(handlePostFlushImmediate:() ‑> Void, defer:Bool = true):Void

Schedule callback that is garanteed to be executed when no immediate callback are pending anymore.

Parameters:

owner

Owner of this callback, allowing to cancel callback if owner is destroyed

handlePostFlushImmediate

The callback to execute

defer

if true (default), will box this call into an immediate callback

flushImmediate():Bool

Execute and flush every awaiting immediate callback, including the ones that could have been added with onceImmediate() after executing the existing callbacks.

Returns:

true if anything was flushed

onceXUpdates(owner:Entity, numUpdates:Int, callback:() ‑> Void):Void

offXUpdates(callback:() ‑> Void):Void

quit():Void

Quit the application. Works on desktop (windows, mac, linux), unity. Can also work on web by closing the window if electron plugin is enabled and the app is running via electron instead of a regular browser.

@:value({ createIfNeeded : true })group(id:String, createIfNeeded:Bool = true):Group<Entity>

Get a group with the given id.

Parameters:

id

The id of the group

createIfNeeded

true (default) to create a group if not created already for this id

Returns:

the group or null if no group was found and none created.

Inherited Events

Defined by Entity

@:dox(show)dispose(entity:Entity):Void

@:dox(show)destroy(entity:Entity):Void

Inherited Variables

Defined by Entity

read onlyhasData:Bool

@:value(null)id:String = null

read onlydestroyed:Bool

read onlydisposed:Bool

@:value(null)read onlyautoruns:Array<Autorun> = null

@editablecomponents:ReadOnlyMap<String, Component>

Public components mapping. Contain components created separately with component() or macro-based components as well.

scriptContent:ScriptContent

Available with script plugin

script:Script

Available with script plugin

Inherited Methods

Defined by Entity

destroy():Void

Destroy this entity. This method is automatically protected from duplicate calls. That means calling multiple times an entity's destroy() method will run the destroy code only one time. As soon as destroy() is called, the entity is marked destroyed=true, even when calling destroy() method on a subclass (a macro is inserting a code to mark the object as destroyed at the beginning of every destroy() override function.

dispose():Void

Schedules destroy, at the end of the current frame.

unbindEvents():Void

Remove all events handlers from this entity.

autorun(run:() ‑> Void, ?afterRun:() ‑> Void):Autorun

Creates a new Autorun instance with the given callback associated with the current entity.

Parameters:

run

The run callback

Returns:

The autorun instance

tween(?easing:Easing, duration:Float, fromValue:Float, toValue:Float, update:(Float, Float) ‑> Void):Tween

component<C>(?name:String, ?component:Null<C>):C