Back

Application

The main object of a game. Initializes basic modules and starts the main loop. More

Properties

RenderManager
Scene
Camera
Importer
Exporter
InputHandler
UIComponent
SoundManager
SoundSource

Methods

constructor
()
Application
( Number width, Number height )
String
( String title )
undefined
( Number dt )
undefined
( Number dt )
undefined
( Number fps )

Description

The most basic Final Engine application is just the creation of an instance of Application:
 var app = new Application();
 
Most applications will import some assets, add them to the scene and update them:
 var app = new Application();

 var character = null;

 app.importer.load( "character", function( ch ) {
      character = ch;
      app.scene.appendChild( character );
  } );

 app.update = function( dt ) {
     if ( character ) {
         character.update( dt );
     }
     else {
         // character has not loaded yet
     }
 };
 
You can get access to the instantiated application from any part of your code by calling the static method Application.getInstance().

Extending Application

You can extend the Application class to write the main application code inside a class.
 function MyApplication() {
    Application.call( this );

    this.cube = new Cube();
    this.scene.appendChild( this.cube );
 }

 MyApplication.extend( Application );

 // in the main file:
 app = new MyApplication();
This provides cleaner code and avoids possible global namespace pollution.

Property Description

Method Description