Skip to content
Benedict Allen edited this page Nov 17, 2015 · 5 revisions

Application class

The Application class contains Screens, which in turn contain all the graphical components on the screen. It is the root node of any program.

Constructor

Application( string name, string path = name )

Callbacks

onUpdate()

Application:onUpdate( number deltaTime )

Called when the Application updates.

onLoad()

Application:onLoad()

Called when the Application loads before being run.

Variables

name

Application.name - string

The name of the Application.

path

Application.path - string

The path to Application files.

terminateable

Application.terminateable - boolean

Specifies whether the Application should stop upon receiving a terminate event.

running

Application.running - boolean

true when the Application is running, false when not.

Methods

registerResourceLoader()

Application:registerResourceLoader( string type, function loader )

Registers a loader to be used with the resource type given.

unregisterResourceLoader()

Application:unregisterResourceLoader( string type )

Unregisters the loader from the resource type given.

registerFileExtension()

Application:registerFileExtension( string extension, string type )

Registers an extension to be associated with a type. If Application:loadResource() is not given a type, its type will be inferred from its extension.

unregisterFileExtension()

Application:unregisterFileExtension( string extension )

Unregisters a file extension.

loadResource()

data = Application:loadResource( string resource, optional string type )

Loads a resource, looking in the application path and root. If type is not given, it will be inferred from the extension of the resource.

addThread()

Thread thread = Application:addThread( Thread thread )

Adds a thread to be resumed by the application, and returns it.

isKeyPressed()

boolean pressed = Application:isKeyPressed( string key )

Returns whether the user is holding the key given.

addScreen()

Screen screen = Application:addScreen()

Adds a blank Screen to the Application.

removeScreen()

Application:removeScreen( Screen screen )

Removes a screen from the Application.

stop()

Application:stop()

Stops the Application from running (exiting Application:run())

run()

Application:run()

Runs the Application, calling load() at the beginning, and catching exceptions thrown.

event()

This is an internal callback.

Application:event( string event, ... )

Used to pass CC formatted events to child Screens.

draw()

This is an internal callback.

Application:draw()

Used to draw child Screens.

update()

This is an internal callback.

Application:update()

Used to update child Screens, while getting the dt using timer.getDelta().

load()

This is an internal callback.

Application:load()

Triggers the onLoad() callback and starts the Application.

Clone this wiki locally