src/App.js
/**
 * Class that manages the application. Changes between states.
 *
 * @param canvasId canvasId the id of the canvas element (or place holder).
 * @param shaders Shaders for WebGL
 * @param initCallback a callback that will be called once all resources are
 *			loaded.
 */
Class that manages the application. Changes between states.
@param canvasId canvasId the id of the canvas element (or place holder).
@param shaders Shaders for WebGL
@param initCallback a callback that will be called once all resources are
loaded.
Class that manages the application . Changes between states . @param canvasId canvasId the id of the canvas element ( or place holder ) . @param shaders Shaders for WebGL @param initCallback a callback that will be called once all resources are loaded .
function App(canvasId, shaders, initCallback) {
	this.canvasId = canvasId;
	this.canvas = null;
	this.shaders = shaders;
	this.initCallback = initCallback;
	this.useGL = true;
	this.webGLFailed = false;
	this.skipToStage = null;
	this.useTouch = false;
	this.frontToBack = false;
	this.debug = false;
	this.debugKeyboardTimeout = 0;
	this.debugAudio = false;
	this.debugMovementTrigger = false;
	this.noTutorial = false;
	this.showFPS = false;
	this.freezeFrame = false;
	this.showSkipButton = false;
	this.skipText = new Text();
	this.resources = new ResourceDepot();
	this.resources.setCallback(createCallback(this.resourceCallback, this));
	ResourceDepot.instance = this.resources;
	var statesList = [ appStates.kStateIntro, IntroState,
		appStates.kStateDeveloperSplash, DeveloperSplashState,
		appStates.kStateMainMenu, MainMenuState,
		appStates.kStateLoadingStage, LoadingStageState,
		appStates.kStateInGame, InGameState,
		appStates.kStateStageComplete, StageCompleteState,
		appStates.kStateYesNoDialog, YesNoDialogState,
		appStates.kStateTutorialPage, TutorialPageState,
		appStates.kStateDialogue, DialogueState,
		appStates.kStoryBoardState, StoryboardState];
	this.fsm = new AppFSM(this, statesList);
	this.newState = -1;
	this.newMessage = null;
	this.stateModes = {
		kStateActive : 0,
		kTransitionOut : 1,
		kTransitionIn : 2
	};
	this.stateMode = this.stateModes.kStateActive;
	this.screenTransition = null;
	this.screenTransitions = [
		{
			from : appStates.kStateIntro,
			to : appStates.kStateDeveloperSplash,
			out : true,
			transition : new ScreenTransitionFade(0.25, new Pixel32(255, 255, 255, 0), new Pixel32(255, 255, 255, 255))
		},
		{
			from : appStates.kStateIntro,
			to : appStates.kStateDeveloperSplash,
			out : false,
			transition : new ScreenTransitionFade(0.25, new Pixel32(255, 255, 255, 255), new Pixel32(255, 255, 255, 0))
		},
		{
			from : appStates.kStateDeveloperSplash,
			to : appStates.kStateMainMenu,
			out : true,
			transition : new ScreenTransitionFade(0.25, new Pixel32(255, 255, 255, 0), new Pixel32(255, 255, 255, 255))
		},
		{
			from : appStates.kStateDeveloperSplash,
			to : appStates.kStateMainMenu,
			out : false,
			transition : new ScreenTransitionFade(0.5, new Pixel32(255, 255, 255, 255), new Pixel32(255, 255, 255, 0))
		}
	];
	this.screenTransitionsDefaultIn = new ScreenTransitionFade(0.25, new Pixel32(0, 0, 0, 255), new Pixel32(0, 0, 0, 0));
	this.screenTransitionsDefaultOut = new ScreenTransitionFade(0.25, new Pixel32(0, 0, 0, 0),
			new Pixel32(0, 0, 0, 255));
	this.audioTransition = new AudioTransition(0.25);
	this.game = new Game(this.resources);
	this.audio = new Audio();
	this.render = null;
	this.fillScreen = true;
	this.aspectRatio = 4 / 3;
	this.maxHeight = 600;
	this.maxWidth = 800;
	this.getURLOptions();
	this.createRender(this.useGL);
	this.initialized = false;
	this.appLoop = null;
	App.instance = this;
	window.addEventListener('resize', createCallback(this.resize, this), false);
	window.addEventListener('orientationchange', createCallback(this.resize, this), false);
	this.frameCount = 0;
	this.frameDate = null;
	this.frameText = null;
	this.frameFont = null;
	this.resources.init();
}
function App ( canvasId , shaders , initCallback ) { this . canvasId = canvasId ; this . canvas = null ; this . shaders = shaders ; this . initCallback = initCallback ; this . useGL = true ; this . webGLFailed = false ; this . skipToStage = null ; this . useTouch = false ; this . frontToBack = false ; this . debug = false ; this . debugKeyboardTimeout = 0 ; this . debugAudio = false ; this . debugMovementTrigger = false ; this . noTutorial = false ; this . showFPS = false ; this . freezeFrame = false ; this . showSkipButton = false ; this . skipText = new Text ( ) ; this . resources = new ResourceDepot ( ) ; this . resources . setCallback ( createCallback ( this . resourceCallback , this ) ) ; ResourceDepot . instance = this . resources ; var statesList = [ appStates . kStateIntro , IntroState , appStates . kStateDeveloperSplash , DeveloperSplashState , appStates . kStateMainMenu , MainMenuState , appStates . kStateLoadingStage , LoadingStageState , appStates . kStateInGame , InGameState , appStates . kStateStageComplete , StageCompleteState , appStates . kStateYesNoDialog , YesNoDialogState , appStates . kStateTutorialPage , TutorialPageState , appStates . kStateDialogue , DialogueState , appStates . kStoryBoardState , StoryboardState ] ; this . fsm = new AppFSM ( this , statesList ) ; this . newState = - 1 ; this . newMessage = null ; this . stateModes = { kStateActive : 0 , kTransitionOut : 1 , kTransitionIn : 2 } ; this . stateMode = this . stateModes . kStateActive ; this . screenTransition = null ; this . screenTransitions = [ { from : appStates . kStateIntro , to : appStates . kStateDeveloperSplash , out : true , transition : new ScreenTransitionFade ( 0.25 , new Pixel32 ( 255 , 255 , 255 , 0 ) , new Pixel32 ( 255 , 255 , 255 , 255 ) ) } , { from : appStates . kStateIntro , to : appStates . kStateDeveloperSplash , out : false , transition : new ScreenTransitionFade ( 0.25 , new Pixel32 ( 255 , 255 , 255 , 255 ) , new Pixel32 ( 255 , 255 , 255 , 0 ) ) } , { from : appStates . kStateDeveloperSplash , to : appStates . kStateMainMenu , out : true , transition : new ScreenTransitionFade ( 0.25 , new Pixel32 ( 255 , 255 , 255 , 0 ) , new Pixel32 ( 255 , 255 , 255 , 255 ) ) } , { from : appStates . kStateDeveloperSplash , to : appStates . kStateMainMenu , out : false , transition : new ScreenTransitionFade ( 0.5 , new Pixel32 ( 255 , 255 , 255 , 255 ) , new Pixel32 ( 255 , 255 , 255 , 0 ) ) } ] ; this . screenTransitionsDefaultIn = new ScreenTransitionFade ( 0.25 , new Pixel32 ( 0 , 0 , 0 , 255 ) , new Pixel32 ( 0 , 0 , 0 , 0 ) ) ; this . screenTransitionsDefaultOut = new ScreenTransitionFade ( 0.25 , new Pixel32 ( 0 , 0 , 0 , 0 ) , new Pixel32 ( 0 , 0 , 0 , 255 ) ) ; this . audioTransition = new AudioTransition ( 0.25 ) ; this . game = new Game ( this . resources ) ; this . audio = new Audio ( ) ; this . render = null ; this . fillScreen = true ; this . aspectRatio = 4 / 3 ; this . maxHeight = 600 ; this . maxWidth = 800 ; this . getURLOptions ( ) ; this . createRender ( this . useGL ) ; this . initialized = false ; this . appLoop = null ; App . instance = this ; window . addEventListener ( 'resize' , createCallback ( this . resize , this ) , false ) ; window . addEventListener ( 'orientationchange' , createCallback ( this . resize , this ) , false ) ; this . frameCount = 0 ; this . frameDate = null ; this . frameText = null ; this . frameFont = null ; this . resources . init ( ) ; }
Class that manages the application.
Class that manages the application .