From 57683361503a20697e3980e500814968388e83e0 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 8 Aug 2013 04:35:13 +0100 Subject: [PATCH] Tidied up the Loader so it now starts automatically, added required Signals and removed the old-style callbacks. --- Phaser/Game.ts | 44 +- Phaser/Stage.ts | 43 +- Phaser/World.ts | 12 +- Phaser/animation/Animation.ts | 22 +- Phaser/cameras/CameraManager.ts | 10 +- Phaser/gameobjects/GameObjectFactory.ts | 34 +- Phaser/input/Gestures.ts | 26 +- Phaser/input/InputManager.ts | 23 ++ Phaser/input/Pointer.ts | 7 +- Phaser/loader/Cache.ts | 14 +- Phaser/loader/Loader.ts | 117 +++--- Phaser/renderers/canvas/CameraRenderer.ts | 10 +- Phaser/system/Device.ts | 9 + Phaser/system/RequestAnimationFrame.ts | 14 +- Phaser/system/StageScaleMode.ts | 56 +-- Phaser/system/screens/BootScreen.ts | 46 +-- Phaser/system/screens/PauseScreen.ts | 42 +- Phaser/tilemap/Tile.ts | 6 +- Phaser/tilemap/TilemapLayer.ts | 2 +- Phaser/tweens/Tween.ts | 20 +- Phaser/tweens/TweenManager.ts | 14 +- Phaser/utils/SpriteUtils.ts | 6 +- README.md | 11 +- Tests/audio/audio sprites 1.js | 5 +- Tests/audio/audio sprites 1.ts | 6 +- Tests/audio/play sound 1.js | 5 +- Tests/audio/play sound 1.ts | 6 +- Tests/buttons/basic button 2.js | 5 +- Tests/buttons/basic button 2.ts | 6 +- Tests/buttons/basic button.js | 5 +- Tests/buttons/basic button.ts | 6 +- Tests/buttons/camera buttons.js | 5 +- Tests/buttons/camera buttons.ts | 6 +- Tests/buttons/rotated buttons.js | 5 +- Tests/buttons/rotated buttons.ts | 6 +- Tests/camera fx/mirror.js | 5 +- Tests/camera fx/mirror.ts | 6 +- Tests/camera fx/scanlines.js | 5 +- Tests/camera fx/scanlines.ts | 6 +- Tests/cameras/basic camera 1.js | 7 +- Tests/cameras/basic camera 1.ts | 10 +- Tests/cameras/basic follow.js | 5 +- Tests/cameras/basic follow.ts | 6 +- Tests/cameras/camera alpha.js | 5 +- Tests/cameras/camera alpha.ts | 6 +- Tests/cameras/camera fx 1.js | 5 +- Tests/cameras/camera fx 1.ts | 6 +- Tests/cameras/camera fx 2.js | 5 +- Tests/cameras/camera fx 2.ts | 6 +- Tests/cameras/camera fx 3.js | 5 +- Tests/cameras/camera fx 3.ts | 6 +- Tests/cameras/camera rotation.js | 5 +- Tests/cameras/camera rotation.ts | 6 +- Tests/cameras/camera scale.js | 5 +- Tests/cameras/camera scale.ts | 6 +- Tests/cameras/camera texture.js | 5 +- Tests/cameras/camera texture.ts | 6 +- Tests/cameras/follow styles.js | 5 +- Tests/cameras/follow styles.ts | 6 +- Tests/cameras/hide from camera.js | 5 +- Tests/cameras/hide from camera.ts | 6 +- Tests/cameras/multi camera.js | 5 +- Tests/cameras/multi camera.ts | 6 +- Tests/cameras/scrollfactor 1.js | 5 +- Tests/cameras/scrollfactor 1.ts | 6 +- Tests/cameras/scrollfactor 2.js | 5 +- Tests/cameras/scrollfactor 2.ts | 6 +- Tests/cameras/scrollfactor compare.js | 5 +- Tests/cameras/scrollfactor compare.ts | 6 +- Tests/cameras/world sprite.js | 5 +- Tests/cameras/world sprite.ts | 6 +- Tests/groups/add to group 1.ts | 6 +- Tests/groups/add to group 2.ts | 6 +- Tests/groups/bring to top 1.js | 5 +- Tests/groups/bring to top 1.ts | 6 +- Tests/groups/bring to top.ts | 6 +- Tests/groups/call all.ts | 6 +- Tests/groups/create group 1.js | 5 +- Tests/groups/create group 1.ts | 6 +- Tests/groups/direct render.ts | 6 +- Tests/groups/display order.js | 5 +- Tests/groups/display order.ts | 6 +- Tests/groups/for each.ts | 6 +- Tests/groups/get first 1.ts | 6 +- Tests/groups/get first 2.ts | 6 +- Tests/groups/get first 3.ts | 6 +- Tests/groups/group as layer.ts | 6 +- Tests/groups/group transform 1.ts | 6 +- Tests/groups/group transform 2.ts | 6 +- Tests/groups/group transform 3.ts | 6 +- Tests/groups/recycle 1.ts | 6 +- Tests/groups/recycle 2.ts | 6 +- Tests/groups/remove.ts | 6 +- Tests/groups/replace.ts | 6 +- Tests/groups/set all.ts | 6 +- Tests/groups/sort 1.ts | 6 +- Tests/groups/sort 2.ts | 6 +- Tests/groups/sub groups.ts | 6 +- Tests/groups/swap children.js | 5 +- Tests/groups/swap children.ts | 6 +- Tests/input/bring to top.js | 5 +- Tests/input/bring to top.ts | 6 +- Tests/input/drag sprite 1.js | 5 +- Tests/input/drag sprite 1.ts | 6 +- Tests/input/drag sprite 2.js | 5 +- Tests/input/drag sprite 2.ts | 6 +- Tests/input/drag sprite 3.js | 5 +- Tests/input/drag sprite 3.ts | 6 +- Tests/input/drop limitation.ts | 6 +- Tests/input/game scale 1.js | 5 +- Tests/input/game scale 1.ts | 6 +- Tests/input/keyboard 1.ts | 6 +- Tests/input/keyboard 2.ts | 6 +- Tests/input/motion lock 2.js | 5 +- Tests/input/motion lock 2.ts | 6 +- Tests/input/motion lock.js | 5 +- Tests/input/motion lock.ts | 6 +- Tests/input/over sprite 1.js | 5 +- Tests/input/over sprite 1.ts | 6 +- Tests/input/over sprite 2.js | 5 +- Tests/input/over sprite 2.ts | 6 +- Tests/input/point in rotated sprite.js | 5 +- Tests/input/point in rotated sprite.ts | 6 +- Tests/input/rotated sprites.js | 5 +- Tests/input/rotated sprites.ts | 6 +- Tests/input/snap 1.js | 5 +- Tests/input/snap 1.ts | 6 +- Tests/input/touch priority.js | 5 +- Tests/input/touch priority.ts | 6 +- Tests/input/world coordinates.js | 5 +- Tests/input/world coordinates.ts | 6 +- Tests/input/world drag.js | 5 +- Tests/input/world drag.ts | 6 +- Tests/misc/color utils 1.ts | 6 +- Tests/misc/color utils 2.ts | 6 +- Tests/misc/color utils 3.ts | 6 +- Tests/misc/dynamic texture 3.ts | 6 +- Tests/misc/point1.js | 5 +- Tests/misc/point1.ts | 6 +- Tests/misc/point2.js | 5 +- Tests/misc/point2.ts | 6 +- Tests/misc/point3.js | 5 +- Tests/misc/point3.ts | 6 +- Tests/mobile/sprite test 1.js | 5 +- Tests/mobile/sprite test 1.ts | 6 +- Tests/particles/graphic emitter.js | 5 +- Tests/particles/graphic emitter.ts | 6 +- Tests/particles/mousetrail.js | 5 +- Tests/particles/mousetrail.ts | 6 +- Tests/particles/multiple streams.js | 5 +- Tests/particles/multiple streams.ts | 6 +- Tests/particles/sprite emitter.js | 5 +- Tests/particles/sprite emitter.ts | 6 +- Tests/particles/when particles collide.js | 5 +- Tests/particles/when particles collide.ts | 6 +- Tests/phaser.js | 472 ++++++++++++---------- Tests/scrollzones/ballscroller.js | 5 +- Tests/scrollzones/ballscroller.ts | 6 +- Tests/scrollzones/blasteroids.js | 5 +- Tests/scrollzones/blasteroids.ts | 6 +- Tests/scrollzones/parallax.js | 5 +- Tests/scrollzones/parallax.ts | 6 +- Tests/scrollzones/region demo.js | 5 +- Tests/scrollzones/region demo.ts | 6 +- Tests/scrollzones/scroll window.js | 5 +- Tests/scrollzones/scroll window.ts | 6 +- Tests/scrollzones/simple scrollzone.js | 5 +- Tests/scrollzones/simple scrollzone.ts | 6 +- Tests/scrollzones/skewed scroller.js | 5 +- Tests/scrollzones/skewed scroller.ts | 6 +- Tests/sprites/alpha.js | 5 +- Tests/sprites/alpha.ts | 6 +- Tests/sprites/animate by framename.js | 5 +- Tests/sprites/animate by framename.ts | 6 +- Tests/sprites/animation 1.js | 5 +- Tests/sprites/animation 1.ts | 6 +- Tests/sprites/animation 2.js | 5 +- Tests/sprites/animation 2.ts | 6 +- Tests/sprites/create sprite 1.js | 5 +- Tests/sprites/create sprite 1.ts | 6 +- Tests/sprites/origin 5.js | 5 +- Tests/sprites/origin 5.ts | 6 +- Tests/sprites/out of screen.ts | 6 +- Tests/sprites/rotate around.ts | 6 +- Tests/sprites/scale sprite 1.js | 5 +- Tests/sprites/scale sprite 1.ts | 6 +- Tests/sprites/scale sprite 2.js | 5 +- Tests/sprites/scale sprite 2.ts | 6 +- Tests/sprites/scale sprite 3.js | 5 +- Tests/sprites/scale sprite 3.ts | 6 +- Tests/sprites/scale sprite 4.js | 5 +- Tests/sprites/scale sprite 4.ts | 6 +- Tests/sprites/scale sprite 5.js | 5 +- Tests/sprites/scale sprite 5.ts | 6 +- Tests/sprites/sprite origin 1.js | 5 +- Tests/sprites/sprite origin 1.ts | 6 +- Tests/sprites/sprite origin 2.js | 5 +- Tests/sprites/sprite origin 2.ts | 6 +- Tests/sprites/sprite origin 3.js | 5 +- Tests/sprites/sprite origin 3.ts | 6 +- Tests/sprites/sprite origin 4.js | 5 +- Tests/sprites/sprite origin 4.ts | 6 +- Tests/stage/blur filter.js | 5 +- Tests/stage/blur filter.ts | 6 +- Tests/stage/brightness filter.js | 5 +- Tests/stage/brightness filter.ts | 6 +- Tests/stage/contrast filter.js | 5 +- Tests/stage/contrast filter.ts | 6 +- Tests/stage/grayscale filter.js | 5 +- Tests/stage/grayscale filter.ts | 6 +- Tests/stage/hue rotate filter.js | 5 +- Tests/stage/hue rotate filter.ts | 6 +- Tests/stage/sepia filter.js | 5 +- Tests/stage/sepia filter.ts | 6 +- Tests/textures/dynamic texture 1.js | 5 +- Tests/textures/dynamic texture 1.ts | 6 +- Tests/textures/filter test.js | 5 +- Tests/textures/filter test.ts | 6 +- Tests/textures/starling texture atlas.js | 5 +- Tests/textures/starling texture atlas.ts | 6 +- Tests/textures/texture atlas 1.js | 5 +- Tests/textures/texture atlas 1.ts | 6 +- Tests/textures/texture atlas 2.js | 5 +- Tests/textures/texture atlas 2.ts | 6 +- Tests/textures/texture atlas 3.js | 5 +- Tests/textures/texture atlas 3.ts | 6 +- Tests/textures/texture atlas 4.js | 5 +- Tests/textures/texture atlas 4.ts | 6 +- Tests/tilemaps/csv tilemap.js | 5 +- Tests/tilemaps/csv tilemap.ts | 6 +- Tests/tilemaps/map draw.js | 5 +- Tests/tilemaps/map draw.ts | 6 +- Tests/tilemaps/tiled layers.js | 5 +- Tests/tilemaps/tiled layers.ts | 6 +- Tests/tilemaps/tiled tilemap.js | 5 +- Tests/tilemaps/tiled tilemap.ts | 6 +- Tests/tweens/bounce.js | 5 +- Tests/tweens/bounce.ts | 6 +- Tests/tweens/easing example 1.ts | 6 +- Tests/tweens/easing example 2.ts | 6 +- Tests/tweens/easing example 3.ts | 6 +- Tests/tweens/easing example 4.ts | 6 +- Tests/tweens/easing example 5.ts | 6 +- Tests/tweens/easing example 6.ts | 6 +- Tests/tweens/tween loop 1.js | 5 +- Tests/tweens/tween loop 1.ts | 6 +- Tests/tweens/tween loop 2.js | 5 +- Tests/tweens/tween loop 2.ts | 6 +- build/phaser.d.ts | 125 +++--- build/phaser.js | 472 ++++++++++++---------- 250 files changed, 1461 insertions(+), 1452 deletions(-) diff --git a/Phaser/Game.ts b/Phaser/Game.ts index 2e78c96d..aec9d53c 100644 --- a/Phaser/Game.ts +++ b/Phaser/Game.ts @@ -52,18 +52,18 @@ module Phaser { * @param parent {string} ID of its parent DOM element. * @param width {number} The width of your game in game pixels. * @param height {number} The height of your game in game pixels. - * @param initCallback {function} Init callback invoked when init default screen. + * @param preloadCallback {function} Preload callback invoked when init default screen. * @param createCallback {function} Create callback invoked when create default screen. * @param updateCallback {function} Update callback invoked when update default screen. * @param renderCallback {function} Render callback invoked when render default screen. * @param destroyCallback {function} Destroy callback invoked when state is destroyed. */ - constructor(callbackContext, parent?: string = '', width?: number = 800, height?: number = 600, initCallback = null, createCallback = null, updateCallback = null, renderCallback = null, destroyCallback = null) { + constructor(callbackContext, parent?: string = '', width?: number = 800, height?: number = 600, preloadCallback = null, createCallback = null, updateCallback = null, renderCallback = null, destroyCallback = null) { this.id = Phaser.GAMES.push(this) - 1; this.callbackContext = callbackContext; - this.onInitCallback = initCallback; + this.onPreloadCallback = preloadCallback; this.onCreateCallback = createCallback; this.onUpdateCallback = updateCallback; this.onRenderCallback = renderCallback; @@ -92,7 +92,7 @@ module Phaser { * Milliseconds of time per step of the game loop. * @type {number} */ - private _step: number = 0; + //private _step: number = 0; /** * Whether load complete loading or not. @@ -133,7 +133,7 @@ module Phaser { * This will be called when init states. (loading assets...) * @type {function} */ - public onInitCallback = null; + public onPreloadCallback = null; /** * This will be called when create states. (setup states...) @@ -314,7 +314,7 @@ module Phaser { this.world = new World(this, width, height); this.add = new GameObjectFactory(this); this.cache = new Cache(this); - this.load = new Loader(this, this.loadComplete); + this.load = new Loader(this); this.time = new TimeManager(this); this.tweens = new TweenManager(this); this.input = new InputManager(this); @@ -323,6 +323,8 @@ module Phaser { this.physics = new Physics.Manager(this); this.plugins = new PluginManager(this, this); + this.load.onLoadComplete.addOnce(this.loadComplete, this); + this.setRenderer(Phaser.Types.RENDERER_CANVAS); this.world.boot(); @@ -337,7 +339,7 @@ module Phaser { DebugUtils.context = this.stage.context; // Display the default game screen? - if (this.onInitCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null) + if (this.onPreloadCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null) { this._raf = new RequestAnimationFrame(this, this.bootLoop); } @@ -382,10 +384,11 @@ module Phaser { } /** - * Called when the load has finished after init was run. + * Called when the load has finished after preload was run. */ private loadComplete() { this._loadComplete = true; + this.onCreateCallback.call(this.callbackContext); } /** @@ -475,13 +478,13 @@ module Phaser { */ private startState() { - if (this.onInitCallback !== null) + if (this.onPreloadCallback !== null) { this.load.reset(); - this.onInitCallback.call(this.callbackContext); + this.onPreloadCallback.call(this.callbackContext); - // Is the load empty? + // Is the loader empty? if (this.load.queueSize == 0) { if (this.onCreateCallback !== null) @@ -491,6 +494,11 @@ module Phaser { this._loadComplete = true; } + else + { + // Start the loader going as we have something in the queue + this.load.start(); + } } else { @@ -507,15 +515,15 @@ module Phaser { /** * Set the most common state callbacks (init, create, update, render). - * @param initCallback {function} Init callback invoked when init state. + * @param preloadCallback {function} Init callback invoked when init state. * @param createCallback {function} Create callback invoked when create state. * @param updateCallback {function} Update callback invoked when update state. * @param renderCallback {function} Render callback invoked when render state. * @param destroyCallback {function} Destroy callback invoked when state is destroyed. */ - public setCallbacks(initCallback = null, createCallback = null, updateCallback = null, renderCallback = null, destroyCallback = null) { + public setCallbacks(preloadCallback = null, createCallback = null, updateCallback = null, renderCallback = null, destroyCallback = null) { - this.onInitCallback = initCallback; + this.onPreloadCallback = preloadCallback; this.onCreateCallback = createCallback; this.onUpdateCallback = updateCallback; this.onRenderCallback = renderCallback; @@ -556,7 +564,7 @@ module Phaser { { this.callbackContext = this.state; - this.onInitCallback = null; + this.onPreloadCallback = null; this.onLoadRenderCallback = null; this.onLoadUpdateCallback = null; this.onCreateCallback = null; @@ -567,9 +575,9 @@ module Phaser { this.onDestroyCallback = null; // Bingo, let's set them up - if (this.state['init']) + if (this.state['preload']) { - this.onInitCallback = this.state['init']; + this.onPreloadCallback = this.state['preload']; } if (this.state['loadRender']) @@ -639,7 +647,7 @@ module Phaser { public destroy() { this.callbackContext = null; - this.onInitCallback = null; + this.onPreloadCallback = null; this.onLoadRenderCallback = null; this.onLoadUpdateCallback = null; this.onCreateCallback = null; diff --git a/Phaser/Stage.ts b/Phaser/Stage.ts index b14f4e54..5e74610f 100644 --- a/Phaser/Stage.ts +++ b/Phaser/Stage.ts @@ -28,7 +28,7 @@ module Phaser { */ constructor(game: Game, parent: string, width: number, height: number) { - this._game = game; + this.game = game; this.canvas = document.createElement('canvas'); this.canvas.width = width; @@ -56,7 +56,7 @@ module Phaser { this.css3 = new Phaser.Display.CSS3Filters(this.canvas); this.scaleMode = StageScaleMode.NO_SCALE; - this.scale = new StageScaleMode(this._game, width, height); + this.scale = new StageScaleMode(this.game, width, height); this.getOffset(this.canvas); this.bounds = new Rectangle(this.offset.x, this.offset.y, width, height); @@ -72,9 +72,9 @@ module Phaser { } /** - * Local private reference to game. + * Local reference to Game. */ - private _game: Game; + public game: Game; /** * Background color of the stage (defaults to black). Set via the public backgroundColor property. @@ -175,21 +175,14 @@ module Phaser { */ public disableVisibilityChange: bool = false; - /** - * An optional 'fix' for the horrendous Android stock browser bug - * https://code.google.com/p/android/issues/detail?id=39247 - * @type {boolean} - */ - public patchAndroidClearRectBug: bool = false; - /** * Stage boot */ public boot() { - this.bootScreen = new BootScreen(this._game); - this.pauseScreen = new PauseScreen(this._game, this.width, this.height); - this.orientationScreen = new OrientationScreen(this._game); + this.bootScreen = new BootScreen(this.game); + this.pauseScreen = new PauseScreen(this.game, this.width, this.height); + this.orientationScreen = new OrientationScreen(this.game); this.scale.setScreenSize(true); @@ -205,9 +198,9 @@ module Phaser { this.context.setTransform(1, 0, 0, 1, 0, 0); - if (this.clear || (this._game.paused && this.disablePauseScreen == false)) + if (this.clear || (this.game.paused && this.disablePauseScreen == false)) { - if (this.patchAndroidClearRectBug) + if (this.game.device.patchAndroidClearRectBug) { this.context.fillStyle = 'rgb(0,0,0)'; this.context.fillRect(0, 0, this.width, this.height); @@ -218,20 +211,20 @@ module Phaser { } } - if (this._game.paused && this.scale.incorrectOrientation) + if (this.game.paused && this.scale.incorrectOrientation) { this.orientationScreen.update(); this.orientationScreen.render(); return; } - if (this._game.isRunning == false && this.disableBootScreen == false) + if (this.game.isRunning == false && this.disableBootScreen == false) { this.bootScreen.update(); this.bootScreen.render(); } - if (this._game.paused && this.disablePauseScreen == false) + if (this.game.paused && this.disablePauseScreen == false) { this.pauseScreen.update(); this.pauseScreen.render(); @@ -251,14 +244,14 @@ module Phaser { if (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] == true || document['webkitHidden'] == true) { - if (this._game.paused == false) + if (this.game.paused == false) { this.pauseGame(); } } else { - if (this._game.paused == true) + if (this.game.paused == true) { this.resumeGame(); } @@ -277,7 +270,7 @@ module Phaser { if ((this.scale.isLandscape && forcePortrait) || (this.scale.isPortrait && forceLandscape)) { // They are in the wrong orientation right now - this._game.paused = true; + this.game.paused = true; this.scale.incorrectOrientation = true; } else @@ -304,7 +297,7 @@ module Phaser { this.saveCanvasValues(); - this._game.paused = true; + this.game.paused = true; } @@ -317,7 +310,7 @@ module Phaser { this.restoreCanvasValues(); - this._game.paused = false; + this.game.paused = false; } @@ -383,7 +376,7 @@ module Phaser { this.context.lineWidth = this.lineWidth; this.context.fillStyle = this.fillStyle; - if (this.patchAndroidClearRectBug) + if (this.game.device.patchAndroidClearRectBug) { this.context.fillStyle = 'rgb(0,0,0)'; this.context.fillRect(0, 0, this.width, this.height); diff --git a/Phaser/World.ts b/Phaser/World.ts index 3d04e365..7260c785 100644 --- a/Phaser/World.ts +++ b/Phaser/World.ts @@ -27,18 +27,18 @@ module Phaser { */ constructor(game: Game, width: number, height: number) { - this._game = game; + this.game = game; - this.cameras = new CameraManager(this._game, 0, 0, width, height); + this.cameras = new CameraManager(this.game, 0, 0, width, height); this.bounds = new Rectangle(0, 0, width, height); } /** - * Local private reference to game. + * Local reference to Game. */ - private _game: Game; + public game: Game; /** * Camera manager of this world. @@ -79,7 +79,7 @@ module Phaser { */ public boot() { - this.group = new Group(this._game, 0); + this.group = new Group(this.game, 0); } @@ -127,7 +127,7 @@ module Phaser { if (updateCameraBounds == true) { - this._game.camera.setBounds(0, 0, width, height); + this.game.camera.setBounds(0, 0, width, height); } // dispatch world resize event diff --git a/Phaser/animation/Animation.ts b/Phaser/animation/Animation.ts index 41f61a5b..b6f6d7cd 100644 --- a/Phaser/animation/Animation.ts +++ b/Phaser/animation/Animation.ts @@ -23,7 +23,7 @@ module Phaser { */ constructor(game: Game, parent: Sprite, frameData: FrameData, name: string, frames, delay: number, looped: bool) { - this._game = game; + this.game = game; this._parent = parent; this._frames = frames; this._frameData = frameData; @@ -41,9 +41,9 @@ module Phaser { } /** - * Local private reference to game. + * Local reference to Game. */ - private _game: Game; + public game: Game; /** * Local private reference to its owner sprite. @@ -167,8 +167,8 @@ module Phaser { this.isPlaying = true; this.isFinished = false; - this._timeLastFrame = this._game.time.now; - this._timeNextFrame = this._game.time.now + this.delay; + this._timeLastFrame = this.game.time.now; + this._timeNextFrame = this.game.time.now + this.delay; this._frameIndex = 0; @@ -188,8 +188,8 @@ module Phaser { this.isPlaying = true; this.isFinished = false; - this._timeLastFrame = this._game.time.now; - this._timeNextFrame = this._game.time.now + this.delay; + this._timeLastFrame = this.game.time.now; + this._timeNextFrame = this.game.time.now + this.delay; this._frameIndex = 0; this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); @@ -211,7 +211,7 @@ module Phaser { */ public update(): bool { - if (this.isPlaying == true && this._game.time.now >= this._timeNextFrame) + if (this.isPlaying == true && this.game.time.now >= this._timeNextFrame) { this._frameIndex++; @@ -233,8 +233,8 @@ module Phaser { this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); } - this._timeLastFrame = this._game.time.now; - this._timeNextFrame = this._game.time.now + this.delay; + this._timeLastFrame = this.game.time.now; + this._timeNextFrame = this.game.time.now + this.delay; return true; } @@ -248,7 +248,7 @@ module Phaser { */ public destroy() { - this._game = null; + this.game = null; this._parent = null; this._frames = null; this._frameData = null; diff --git a/Phaser/cameras/CameraManager.ts b/Phaser/cameras/CameraManager.ts index bd9a9153..5498d2d3 100644 --- a/Phaser/cameras/CameraManager.ts +++ b/Phaser/cameras/CameraManager.ts @@ -23,7 +23,7 @@ module Phaser { */ constructor(game: Game, x: number, y: number, width: number, height: number) { - this._game = game; + this.game = game; this._cameras = []; this._cameraLength = 0; @@ -35,9 +35,9 @@ module Phaser { } /** - * Local private reference to Game. + * Local reference to Game. */ - private _game: Game; + public game: Game; /** * Local container for storing cameras. @@ -113,7 +113,7 @@ module Phaser { */ public addCamera(x: number, y: number, width: number, height: number): Camera { - var newCam: Camera = new Camera(this._game, this._cameraLength, x, y, width, height); + var newCam: Camera = new Camera(this.game, this._cameraLength, x, y, width, height); this._cameraLength = this._cameras.push(newCam); @@ -230,7 +230,7 @@ module Phaser { this._cameras.length = 0; - this.current = this.addCamera(0, 0, this._game.stage.width, this._game.stage.height); + this.current = this.addCamera(0, 0, this.game.stage.width, this.game.stage.height); } diff --git a/Phaser/gameobjects/GameObjectFactory.ts b/Phaser/gameobjects/GameObjectFactory.ts index d74c8a03..69aaffb5 100644 --- a/Phaser/gameobjects/GameObjectFactory.ts +++ b/Phaser/gameobjects/GameObjectFactory.ts @@ -24,15 +24,15 @@ module Phaser { */ constructor(game: Phaser.Game) { - this._game = game; - this._world = this._game.world; + this.game = game; + this._world = this.game.world; } /** - * Local private reference to Game + * Local reference to Game */ - private _game: Phaser.Game; + public game: Phaser.Game; /** * Local private reference to World @@ -60,7 +60,7 @@ module Phaser { * @returns {GeomSprite} The newly created geom sprite object. */ //public geomSprite(x: number, y: number): GeomSprite { - // return this._world.group.add(new GeomSprite(this._game, x, y)); + // return this._world.group.add(new GeomSprite(this.game, x, y)); //} /** @@ -77,7 +77,7 @@ module Phaser { * @returns {Button} The newly created button object. */ public button(x?: number = 0, y?: number = 0, key?: string = null, callback? = null, callbackContext? = null, overFrame? = null, outFrame? = null, downFrame? = null): UI.Button { - return this._world.group.add(new UI.Button(this._game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame)); + return this._world.group.add(new UI.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame)); } /** @@ -90,11 +90,11 @@ module Phaser { * @returns {Sprite} The newly created sprite object. */ public sprite(x: number, y: number, key?: string = '', frame? = null): Sprite { - return this._world.group.add(new Sprite(this._game, x, y, key, frame)); + return this._world.group.add(new Sprite(this.game, x, y, key, frame)); } public audio(key: string, volume?: number = 1, loop?: bool = false) { - return this._game.sound.add(key, volume, loop); + return this.game.sound.add(key, volume, loop); } /** @@ -109,7 +109,7 @@ module Phaser { * @returns {Sprite} The newly created sprite object. */ //public physicsSprite(x: number, y: number, key?: string = '', frame? = null, bodyType?: number = Phaser.Types.BODY_DYNAMIC, shapeType?:number = 0): Sprite { - // return this._world.group.add(new Sprite(this._game, x, y, key, frame, bodyType, shapeType)); + // return this._world.group.add(new Sprite(this.game, x, y, key, frame, bodyType, shapeType)); //} /** @@ -120,7 +120,7 @@ module Phaser { * @returns {DynamicTexture} The newly created dynamic texture object. */ public dynamicTexture(width: number, height: number): DynamicTexture { - return new DynamicTexture(this._game, width, height); + return new DynamicTexture(this.game, width, height); } /** @@ -130,7 +130,7 @@ module Phaser { * @returns {Group} The newly created group. */ public group(maxSize?: number = 0): Group { - return this._world.group.add(new Group(this._game, maxSize)); + return this._world.group.add(new Group(this.game, maxSize)); } /** @@ -139,7 +139,7 @@ module Phaser { * @return {Particle} The newly created particle object. */ public particle(): ArcadeParticle { - return new ArcadeParticle(this._game); + return new ArcadeParticle(this.game); } /** @@ -151,7 +151,7 @@ module Phaser { * @return {Emitter} The newly created emitter object. */ public emitter(x?: number = 0, y?: number = 0, size?: number = 0): ArcadeEmitter { - return this._world.group.add(new ArcadeEmitter(this._game, x, y, size)); + return this._world.group.add(new ArcadeEmitter(this.game, x, y, size)); } /** @@ -165,7 +165,7 @@ module Phaser { * @returns {ScrollZone} The newly created scroll zone object. */ public scrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone { - return this._world.group.add(new ScrollZone(this._game, key, x, y, width, height)); + return this._world.group.add(new ScrollZone(this.game, key, x, y, width, height)); } /** @@ -180,7 +180,7 @@ module Phaser { * @return {Tilemap} The newly created tilemap object. */ public tilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap { - return this._world.group.add(new Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight)); + return this._world.group.add(new Tilemap(this.game, key, mapData, format, resizeWorld, tileWidth, tileHeight)); } /** @@ -191,7 +191,7 @@ module Phaser { * @return {Phaser.Tween} The newly created tween object. */ public tween(obj, localReference?:bool = false): Tween { - return this._game.tweens.create(obj, localReference); + return this.game.tweens.create(obj, localReference); } /** @@ -279,7 +279,7 @@ module Phaser { * @return {Phaser.Tween} The Tween object */ public existingTween(tween: Tween): Tween { - return this._game.tweens.add(tween); + return this.game.tweens.add(tween); } } diff --git a/Phaser/input/Gestures.ts b/Phaser/input/Gestures.ts index 7a18a6a2..71cb2a3f 100644 --- a/Phaser/input/Gestures.ts +++ b/Phaser/input/Gestures.ts @@ -19,17 +19,17 @@ module Phaser { */ constructor(game: Game) { - this._game = game; + this.game = game; } /** - * Local private reference to game. + * Local reference to Game. * @property _game * @type {Game} * @private **/ - private _game: Game; + public game: Game; private _p1: Pointer; private _p2: Pointer; @@ -45,16 +45,16 @@ module Phaser { public start() { // Local references to the Phaser.Input.pointer objects - this._p1 = this._game.input.pointer1; - this._p2 = this._game.input.pointer2; - this._p3 = this._game.input.pointer3; - this._p4 = this._game.input.pointer4; - this._p5 = this._game.input.pointer5; - this._p6 = this._game.input.pointer6; - this._p7 = this._game.input.pointer7; - this._p8 = this._game.input.pointer8; - this._p9 = this._game.input.pointer9; - this._p10 = this._game.input.pointer10; + this._p1 = this.game.input.pointer1; + this._p2 = this.game.input.pointer2; + this._p3 = this.game.input.pointer3; + this._p4 = this.game.input.pointer4; + this._p5 = this.game.input.pointer5; + this._p6 = this.game.input.pointer6; + this._p7 = this.game.input.pointer7; + this._p8 = this.game.input.pointer8; + this._p9 = this.game.input.pointer9; + this._p10 = this.game.input.pointer10; } diff --git a/Phaser/input/InputManager.ts b/Phaser/input/InputManager.ts index 2f5bc0ec..85e7f577 100644 --- a/Phaser/input/InputManager.ts +++ b/Phaser/input/InputManager.ts @@ -60,6 +60,15 @@ module Phaser { */ public game: Game; + /** + * How often should the input pointers be checked for updates? + * A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on. + * @type {number} + */ + public pollRate: number = 0; + + private _pollCounter: number = 0; + /** * A 1x1 sized canvas used for pixel-perfect checks * @type {HTMLCanvasElement} @@ -495,12 +504,22 @@ module Phaser { } + public get pollLocked(): bool { + return (this.pollRate > 0 && this._pollCounter < this.pollRate); + } + /** * Updates the Input Manager. Called by the core Game loop. * @method update **/ public update() { + if (this.pollRate > 0 && this._pollCounter < this.pollRate) + { + this._pollCounter++; + return; + } + this.speed.x = this.position.x - this._oldPosition.x; this.speed.y = this.position.y - this._oldPosition.y; @@ -519,6 +538,8 @@ module Phaser { if (this.pointer9) { this.pointer9.update(); } if (this.pointer10) { this.pointer10.update(); } + this._pollCounter = 0; + } /** @@ -568,6 +589,8 @@ module Phaser { this.totalTrackedObjects = 0; } + this._pollCounter = 0; + } public resetSpeed(x: number, y: number) { diff --git a/Phaser/input/Pointer.ts b/Phaser/input/Pointer.ts index d6b85ac8..2ba126db 100644 --- a/Phaser/input/Pointer.ts +++ b/Phaser/input/Pointer.ts @@ -38,7 +38,7 @@ module Phaser { private _highestInputPriorityID: number; /** - * Local private reference to game. + * Local reference to Game. * @property game * @type {Phaser.Game} * @private @@ -419,6 +419,11 @@ module Phaser { */ public move(event): Pointer { + if (this.game.input.pollLocked) + { + return; + } + if (event.button) { this.button = event.button; diff --git a/Phaser/loader/Cache.ts b/Phaser/loader/Cache.ts index 8fd5b902..4f7b434b 100644 --- a/Phaser/loader/Cache.ts +++ b/Phaser/loader/Cache.ts @@ -16,7 +16,7 @@ module Phaser { */ constructor(game: Game) { - this._game = game; + this.game = game; this._canvases = {}; this._images = {}; @@ -26,9 +26,9 @@ module Phaser { } /** - * Local private reference to game. + * Local reference to Game. */ - private _game: Game; + public game: Game; /** * Canvas key-value container. @@ -78,7 +78,7 @@ module Phaser { public addSpriteSheet(key: string, url: string, data, frameWidth: number, frameHeight: number, frameMax: number) { this._images[key] = { url: url, data: data, spriteSheet: true, frameWidth: frameWidth, frameHeight: frameHeight }; - this._images[key].frameData = AnimationLoader.parseSpriteSheet(this._game, key, frameWidth, frameHeight, frameMax); + this._images[key].frameData = AnimationLoader.parseSpriteSheet(this.game, key, frameWidth, frameHeight, frameMax); } @@ -95,11 +95,11 @@ module Phaser { if (format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY) { - this._images[key].frameData = AnimationLoader.parseJSONData(this._game, atlasData); + this._images[key].frameData = AnimationLoader.parseJSONData(this.game, atlasData); } else if (format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING) { - this._images[key].frameData = AnimationLoader.parseXMLData(this._game, atlasData, format); + this._images[key].frameData = AnimationLoader.parseXMLData(this.game, atlasData, format); } } @@ -124,7 +124,7 @@ module Phaser { */ public addSound(key: string, url: string, data, webAudio: bool = true, audioTag: bool = false) { - var locked: bool = this._game.sound.touchLocked; + var locked: bool = this.game.sound.touchLocked; var decoded: bool = false; if (audioTag) { diff --git a/Phaser/loader/Loader.ts b/Phaser/loader/Loader.ts index 537fd6f2..c7d3dd63 100644 --- a/Phaser/loader/Loader.ts +++ b/Phaser/loader/Loader.ts @@ -15,26 +15,31 @@ module Phaser { * Loader constructor * * @param game {Phaser.Game} Current game instance. - * @param callback {function} This will be called when assets completely loaded. */ - constructor(game: Game, callback) { + constructor(game: Game) { + + this.game = game; - this._game = game; - this._gameCreateComplete = callback; this._keys = []; this._fileList = {}; this._xhr = new XMLHttpRequest(); this._queueSize = 0; + this.isLoading = false; + + this.onFileComplete = new Phaser.Signal; + this.onFileError = new Phaser.Signal; + this.onLoadStart = new Phaser.Signal; + this.onLoadComplete = new Phaser.Signal; } /** - * Local private reference to game. + * Local reference to Game. */ - private _game: Game; + public game: Game; /** - * Array stors assets keys. So you can get that asset by its unique key. + * Array stores assets keys. So you can get that asset by its unique key. */ private _keys: string[]; @@ -43,13 +48,6 @@ module Phaser { */ private _fileList; - /** - * Game initialial assets loading callback. - */ - private _gameCreateComplete; - private _onComplete; - private _onFileLoad; - /** * Indicates assets loading progress. (from 0 to 100) * @type {number} @@ -64,6 +62,12 @@ module Phaser { */ private _queueSize: number; + /** + * True if the Loader is in the process of loading a queue. + * @type {boolean} + */ + public isLoading: bool; + /** * True if game is completely loaded. * @type {boolean} @@ -82,6 +86,11 @@ module Phaser { */ public crossOrigin: string = ''; + public onFileComplete: Phaser.Signal; + public onFileError: Phaser.Signal; + public onLoadStart: Phaser.Signal; + public onLoadComplete: Phaser.Signal; + /** * TextureAtlas data format constants */ @@ -94,6 +103,7 @@ module Phaser { */ public reset() { this._queueSize = 0; + this.isLoading = false; } public get queueSize(): number { @@ -269,22 +279,19 @@ module Phaser { /** * Load assets. - * @param onFileLoadCallback {function} Called when each file loaded successfully. - * @param onCompleteCallback {function} Called when all assets completely loaded. */ - public start(onFileLoadCallback = null, onCompleteCallback = null) { + public start() { + + if (this.isLoading) + { + return; + } this.progress = 0; this.hasLoaded = false; + this.isLoading = true; - this._onComplete = onCompleteCallback; - - if (onCompleteCallback == null) - { - this._onComplete = this._game.onCreateCallback; - } - - this._onFileLoad = onFileLoadCallback; + this.onLoadStart.dispatch(this.queueSize); if (this._keys.length > 0) { @@ -295,12 +302,7 @@ module Phaser { { this.progress = 100; this.hasLoaded = true; - this._gameCreateComplete.call(this._game); - - if (this._onComplete !== null) - { - this._onComplete.call(this._game.callbackContext); - } + this.onLoadComplete.dispatch(); } } @@ -334,7 +336,7 @@ module Phaser { if (file.url !== null) { // WebAudio or Audio Tag? - if (this._game.sound.usingWebAudio) + if (this.game.sound.usingWebAudio) { this._xhr.open("GET", file.url, true); this._xhr.responseType = "arraybuffer"; @@ -342,9 +344,9 @@ module Phaser { this._xhr.onerror = () => this.fileError(file.key); this._xhr.send(); } - else if (this._game.sound.usingAudioTag) + else if (this.game.sound.usingAudioTag) { - if (this._game.sound.touchLocked) + if (this.game.sound.touchLocked) { // If audio is locked we can't do this yet, so need to queue this load request somehow. Bum. file.data = new Audio(); @@ -360,7 +362,7 @@ module Phaser { file.data.onerror = () => this.fileError(file.key); file.data.preload = 'auto'; file.data.src = file.url; - file.data.addEventListener('canplaythrough', Phaser.GAMES[this._game.id].load.fileComplete(file.key), false); + file.data.addEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete(file.key), false); file.data.load(); } } @@ -388,10 +390,8 @@ module Phaser { extension = urls[i].toLowerCase(); extension = extension.substr((Math.max(0, extension.lastIndexOf(".")) || Infinity) + 1); - if (this._game.device.canPlayAudio(extension)) + if (this.game.device.canPlayAudio(extension)) { - //console.log('getAudioURL', urls[i]); - //console.log(urls[i]); return urls[i]; } @@ -410,6 +410,8 @@ module Phaser { this._fileList[key].loaded = true; this._fileList[key].error = true; + this.onFileError.dispatch(key); + throw new Error("Phaser.Loader error loading file: " + key); this.nextFile(key, false); @@ -436,17 +438,17 @@ module Phaser { switch (file.type) { case 'image': - this._game.cache.addImage(file.key, file.url, file.data); + this.game.cache.addImage(file.key, file.url, file.data); break; case 'spritesheet': - this._game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax); + this.game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax); break; case 'textureatlas': if (file.atlasURL == null) { - this._game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format); + this.game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format); } else { @@ -471,37 +473,37 @@ module Phaser { case 'audio': - if (this._game.sound.usingWebAudio) + if (this.game.sound.usingWebAudio) { file.data = this._xhr.response; - this._game.cache.addSound(file.key, file.url, file.data, true, false); + this.game.cache.addSound(file.key, file.url, file.data, true, false); if (file.autoDecode) { - this._game.cache.updateSound(key, 'isDecoding', true); + this.game.cache.updateSound(key, 'isDecoding', true); var that = this; var key = file.key; - this._game.sound.context.decodeAudioData(file.data, function (buffer) { + this.game.sound.context.decodeAudioData(file.data, function (buffer) { if (buffer) { - that._game.cache.decodedSound(key, buffer); + that.game.cache.decodedSound(key, buffer); } }); } } else { - file.data.removeEventListener('canplaythrough', Phaser.GAMES[this._game.id].load.fileComplete); - this._game.cache.addSound(file.key, file.url, file.data, false, true); + file.data.removeEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete); + this.game.cache.addSound(file.key, file.url, file.data, false, true); } break; case 'text': file.data = this._xhr.response; - this._game.cache.addText(file.key, file.url, file.data); + this.game.cache.addText(file.key, file.url, file.data); break; } @@ -521,7 +523,7 @@ module Phaser { var data = JSON.parse(this._xhr.response); var file = this._fileList[key]; - this._game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format); + this.game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format); this.nextFile(key, true); @@ -573,7 +575,7 @@ module Phaser { } var file = this._fileList[key]; - this._game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format); + this.game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format); this.nextFile(key, true); @@ -593,10 +595,7 @@ module Phaser { this.progress = 100; } - if (this._onFileLoad) - { - this._onFileLoad.call(this._game.callbackContext, this.progress, previousKey, success); - } + this.onFileComplete.dispatch(this.progress, previousKey, success, this._queueSize - this._keys.length, this._queueSize); if (this._keys.length > 0) { @@ -605,13 +604,11 @@ module Phaser { else { this.hasLoaded = true; + this.isLoading = false; + this.removeAll(); - this._gameCreateComplete.call(this._game); - if (this._onComplete !== null) - { - this._onComplete.call(this._game.callbackContext); - } + this.onLoadComplete.dispatch(); } } diff --git a/Phaser/renderers/canvas/CameraRenderer.ts b/Phaser/renderers/canvas/CameraRenderer.ts index dda16d88..a7885695 100644 --- a/Phaser/renderers/canvas/CameraRenderer.ts +++ b/Phaser/renderers/canvas/CameraRenderer.ts @@ -39,7 +39,15 @@ module Phaser.Renderer.Canvas { return false; } - camera.texture.context.clearRect(0, 0, camera.width, camera.height); + if (this.game.device.patchAndroidClearRectBug) + { + camera.texture.context.fillStyle = 'rgb(0,0,0)'; + camera.texture.context.fillRect(0, 0, camera.width, camera.height); + } + else + { + camera.texture.context.clearRect(0, 0, camera.width, camera.height); + } // Alpha if (camera.texture.alpha !== 1 && camera.texture.context.globalAlpha != camera.texture.alpha) diff --git a/Phaser/system/Device.ts b/Phaser/system/Device.ts index cb6d71b5..c82256a7 100644 --- a/Phaser/system/Device.ts +++ b/Phaser/system/Device.ts @@ -25,6 +25,15 @@ module Phaser { } + // Android bug specific :) + + /** + * An optional 'fix' for the horrendous Android stock browser bug + * https://code.google.com/p/android/issues/detail?id=39247 + * @type {boolean} + */ + public patchAndroidClearRectBug: bool = false; + // Operating System /** diff --git a/Phaser/system/RequestAnimationFrame.ts b/Phaser/system/RequestAnimationFrame.ts index 921510ba..de43ce9f 100644 --- a/Phaser/system/RequestAnimationFrame.ts +++ b/Phaser/system/RequestAnimationFrame.ts @@ -17,7 +17,7 @@ module Phaser { */ constructor(game: Game, callback) { - this._game = game; + this.game = game; this.callback = callback; var vendors = ['ms', 'moz', 'webkit', 'o']; @@ -33,9 +33,9 @@ module Phaser { } /** - * Local private reference to game. + * Local reference to Game. */ - private _game: Game; + public game: Game; /** * The function to be called each frame. Will be called in the context of _game @@ -148,11 +148,11 @@ module Phaser { **/ public RAFUpdate(time: number) { - this._game.time.update(time); + this.game.time.update(time); if (this.callback) { - this.callback.call(this._game); + this.callback.call(this.game); } this._onLoop = (time) => this.RAFUpdate(time); @@ -167,7 +167,7 @@ module Phaser { **/ public SetTimeoutUpdate() { - this._game.time.update(Date.now()); + this.game.time.update(Date.now()); this._onLoop = () => this.SetTimeoutUpdate(); @@ -175,7 +175,7 @@ module Phaser { if (this.callback) { - this.callback.call(this._game); + this.callback.call(this.game); } } diff --git a/Phaser/system/StageScaleMode.ts b/Phaser/system/StageScaleMode.ts index 96486fab..3d80364f 100644 --- a/Phaser/system/StageScaleMode.ts +++ b/Phaser/system/StageScaleMode.ts @@ -17,7 +17,7 @@ module Phaser { */ constructor(game: Game, width: number, height: number) { - this._game = game; + this.game = game; this.enterLandscape = new Phaser.Signal(); this.enterPortrait = new Phaser.Signal(); @@ -51,9 +51,9 @@ module Phaser { } /** - * Local private reference to game. + * Local reference to Game. */ - private _game: Game; + public game: Game; /** * Stage height when start the game. @@ -208,7 +208,7 @@ module Phaser { return; } - var element = this._game.stage.canvas; + var element = this.game.stage.canvas; if (element['requestFullScreen']) { @@ -247,7 +247,7 @@ module Phaser { */ public update() { - if (this._game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height)) + if (this.game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height)) { this.refresh(); } @@ -267,7 +267,7 @@ module Phaser { if ((this.forceLandscape && window.innerWidth > window.innerHeight) || (this.forcePortrait && window.innerHeight > window.innerWidth)) { // Back to normal - this._game.paused = false; + this.game.paused = false; this.incorrectOrientation = false; this.refresh(); } @@ -277,7 +277,7 @@ module Phaser { if ((this.forceLandscape && window.innerWidth < window.innerHeight) || (this.forcePortrait && window.innerHeight < window.innerWidth)) { // Show orientation screen - this._game.paused = true; + this.game.paused = true; this.incorrectOrientation = true; this.refresh(); } @@ -309,7 +309,7 @@ module Phaser { this.enterPortrait.dispatch(this.orientation, false, true); } - if (this._game.stage.scaleMode !== StageScaleMode.NO_SCALE) + if (this.game.stage.scaleMode !== StageScaleMode.NO_SCALE) { this.refresh(); } @@ -339,7 +339,7 @@ module Phaser { this.enterPortrait.dispatch(this.orientation, false, true); } - if (this._game.stage.scaleMode !== StageScaleMode.NO_SCALE) + if (this.game.stage.scaleMode !== StageScaleMode.NO_SCALE) { this.refresh(); } @@ -352,13 +352,13 @@ module Phaser { private refresh() { // We can't do anything about the status bars in iPads, web apps or desktops - if (this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false) + if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false) { document.documentElement.style.minHeight = '2000px'; this._startHeight = window.innerHeight; - if (this._game.device.android && this._game.device.chrome == false) + if (this.game.device.android && this.game.device.chrome == false) { window.scrollTo(0, 1); } @@ -382,9 +382,9 @@ module Phaser { */ public setScreenSize(force: bool = false) { - if (this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false) + if (this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false) { - if (this._game.device.android && this._game.device.chrome == false) + if (this.game.device.android && this.game.device.chrome == false) { window.scrollTo(0, 1); } @@ -405,11 +405,11 @@ module Phaser { { this.setMaximum(); } - else if (this._game.stage.scaleMode == StageScaleMode.EXACT_FIT) + else if (this.game.stage.scaleMode == StageScaleMode.EXACT_FIT) { this.setExactFit(); } - else if (this._game.stage.scaleMode == StageScaleMode.SHOW_ALL) + else if (this.game.stage.scaleMode == StageScaleMode.SHOW_ALL) { this.setShowAll(); } @@ -449,20 +449,20 @@ module Phaser { } } - this._game.stage.canvas.style.width = this.width + 'px'; - this._game.stage.canvas.style.height = this.height + 'px'; + this.game.stage.canvas.style.width = this.width + 'px'; + this.game.stage.canvas.style.height = this.height + 'px'; - this._game.input.scale.setTo(this._game.stage.width / this.width, this._game.stage.height / this.height); + this.game.input.scale.setTo(this.game.stage.width / this.width, this.game.stage.height / this.height); if (this.pageAlignHorizontally) { if (this.width < window.innerWidth && this.incorrectOrientation == false) { - this._game.stage.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px'; + this.game.stage.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px'; } else { - this._game.stage.canvas.style.marginLeft = '0px'; + this.game.stage.canvas.style.marginLeft = '0px'; } } @@ -470,19 +470,19 @@ module Phaser { { if (this.height < window.innerHeight && this.incorrectOrientation == false) { - this._game.stage.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px'; + this.game.stage.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px'; } else { - this._game.stage.canvas.style.marginTop = '0px'; + this.game.stage.canvas.style.marginTop = '0px'; } } - this._game.stage.getOffset(this._game.stage.canvas); + this.game.stage.getOffset(this.game.stage.canvas); this.aspectRatio = this.width / this.height; - this.scaleFactor.x = this._game.stage.width / this.width; - this.scaleFactor.y = this._game.stage.height / this.height; + this.scaleFactor.x = this.game.stage.width / this.width; + this.scaleFactor.y = this.game.stage.height / this.height; } @@ -495,10 +495,10 @@ module Phaser { private setShowAll() { - var multiplier = Math.min((window.innerHeight / this._game.stage.height), (window.innerWidth / this._game.stage.width)); + var multiplier = Math.min((window.innerHeight / this.game.stage.height), (window.innerWidth / this.game.stage.width)); - this.width = Math.round(this._game.stage.width * multiplier); - this.height = Math.round(this._game.stage.height * multiplier); + this.width = Math.round(this.game.stage.width * multiplier); + this.height = Math.round(this.game.stage.height * multiplier); } diff --git a/Phaser/system/screens/BootScreen.ts b/Phaser/system/screens/BootScreen.ts index b84d6c76..094479e3 100644 --- a/Phaser/system/screens/BootScreen.ts +++ b/Phaser/system/screens/BootScreen.ts @@ -19,7 +19,7 @@ module Phaser { */ constructor(game:Game) { - this._game = game; + this.game = game; this._logo = new Image(); this._logo.src = this._logoData; @@ -27,9 +27,9 @@ module Phaser { } /** - * Local private reference to game. + * Local reference to Game. */ - private _game: Game; + public game: Game; /** * Engine logo. */ @@ -76,34 +76,34 @@ module Phaser { */ public render() { - var grd = this._game.stage.context.createLinearGradient(0, 0, 0, this._game.stage.height); + var grd = this.game.stage.context.createLinearGradient(0, 0, 0, this.game.stage.height); grd.addColorStop(0, 'rgb(' + this._color1.r + ', ' + this._color1.g + ', ' + this._color1.b + ')'); grd.addColorStop(0.5, 'rgb(' + this._color2.r + ', ' + this._color2.g + ', ' + this._color2.b + ')'); grd.addColorStop(1, 'rgb(' + this._color1.r + ', ' + this._color1.g + ', ' + this._color1.b + ')'); - this._game.stage.context.fillStyle = grd; - this._game.stage.context.fillRect(0, 0, this._game.stage.width, this._game.stage.height); + this.game.stage.context.fillStyle = grd; + this.game.stage.context.fillRect(0, 0, this.game.stage.width, this.game.stage.height); - this._game.stage.context.shadowOffsetX = 0; - this._game.stage.context.shadowOffsetY = 0; + this.game.stage.context.shadowOffsetX = 0; + this.game.stage.context.shadowOffsetY = 0; if (this._logo) { - this._game.stage.context.drawImage(this._logo, 32, 32); + this.game.stage.context.drawImage(this._logo, 32, 32); } - this._game.stage.context.shadowColor = 'rgb(0,0,0)'; - this._game.stage.context.shadowOffsetX = 1; - this._game.stage.context.shadowOffsetY = 1; - this._game.stage.context.shadowBlur = 0; - this._game.stage.context.fillStyle = 'rgb(255,255,255)'; - this._game.stage.context.font = 'bold 18px Arial'; - this._game.stage.context.textBaseline = 'top'; - this._game.stage.context.fillText(Phaser.VERSION, 32, 64+32); - this._game.stage.context.fillText('Game Size: ' + this._game.stage.width + ' x ' + this._game.stage.height, 32, 64+64); - this._game.stage.context.fillText('www.photonstorm.com', 32, 64+96); - this._game.stage.context.font = '16px Arial'; - this._game.stage.context.fillText('You are seeing this screen because you didn\'t specify any default', 32, 64+160); - this._game.stage.context.fillText('functions in the Game constructor or use Game.switchState()', 32, 64+184); + this.game.stage.context.shadowColor = 'rgb(0,0,0)'; + this.game.stage.context.shadowOffsetX = 1; + this.game.stage.context.shadowOffsetY = 1; + this.game.stage.context.shadowBlur = 0; + this.game.stage.context.fillStyle = 'rgb(255,255,255)'; + this.game.stage.context.font = 'bold 18px Arial'; + this.game.stage.context.textBaseline = 'top'; + this.game.stage.context.fillText(Phaser.VERSION, 32, 64+32); + this.game.stage.context.fillText('Game Size: ' + this.game.stage.width + ' x ' + this.game.stage.height, 32, 64+64); + this.game.stage.context.fillText('www.photonstorm.com', 32, 64+96); + this.game.stage.context.font = '16px Arial'; + this.game.stage.context.fillText('You are seeing this screen because you didn\'t specify any default', 32, 64+160); + this.game.stage.context.fillText('functions in the Game constructor or use Game.switchState()', 32, 64+184); } @@ -112,7 +112,7 @@ module Phaser { */ private colorCycle() { - this._fade = this._game.add.tween(this._color2); + this._fade = this.game.add.tween(this._color2); this._fade.to({ r: Math.random() * 250, g: Math.random() * 250, b: Math.random() * 250 }, 3000, Phaser.Easing.Linear.None); this._fade.onComplete.add(this.colorCycle, this); diff --git a/Phaser/system/screens/PauseScreen.ts b/Phaser/system/screens/PauseScreen.ts index 875c59a9..a2c2e9d5 100644 --- a/Phaser/system/screens/PauseScreen.ts +++ b/Phaser/system/screens/PauseScreen.ts @@ -19,7 +19,7 @@ module Phaser { */ constructor(game: Game, width: number, height: number) { - this._game = game; + this.game = game; this._canvas = document.createElement('canvas'); this._canvas.width = width; this._canvas.height = height; @@ -28,9 +28,9 @@ module Phaser { } /** - * Local private reference to game. + * Local reference to Game. */ - private _game: Game; + public game: Game; /** * Canvas element used by engine. @@ -62,7 +62,7 @@ module Phaser { // Take a grab of the current canvas to our temporary one this._context.clearRect(0, 0, this._canvas.width, this._canvas.height); - this._context.drawImage(this._game.stage.canvas, 0, 0); + this._context.drawImage(this.game.stage.canvas, 0, 0); this._color = { r: 255, g: 255, b: 255 }; this.fadeOut(); @@ -73,7 +73,7 @@ module Phaser { */ public onResume() { this._fade.stop(); - this._game.tweens.remove(this._fade); + this.game.tweens.remove(this._fade); } /** @@ -90,25 +90,25 @@ module Phaser { */ public render() { - this._game.stage.context.drawImage(this._canvas, 0, 0); + this.game.stage.context.drawImage(this._canvas, 0, 0); - this._game.stage.context.fillStyle = 'rgba(0, 0, 0, 0.4)'; - this._game.stage.context.fillRect(0, 0, this._game.stage.width, this._game.stage.height); + this.game.stage.context.fillStyle = 'rgba(0, 0, 0, 0.4)'; + this.game.stage.context.fillRect(0, 0, this.game.stage.width, this.game.stage.height); // Draw a 'play' arrow - var arrowWidth = Math.round(this._game.stage.width / 2); - var arrowHeight = Math.round(this._game.stage.height / 2); + var arrowWidth = Math.round(this.game.stage.width / 2); + var arrowHeight = Math.round(this.game.stage.height / 2); - var sx = this._game.stage.centerX - arrowWidth / 2; - var sy = this._game.stage.centerY - arrowHeight / 2; + var sx = this.game.stage.centerX - arrowWidth / 2; + var sy = this.game.stage.centerY - arrowHeight / 2; - this._game.stage.context.beginPath(); - this._game.stage.context.moveTo(sx, sy); - this._game.stage.context.lineTo(sx, sy + arrowHeight); - this._game.stage.context.lineTo(sx + arrowWidth, this._game.stage.centerY); - this._game.stage.context.fillStyle = 'rgba(' + this._color.r + ', ' + this._color.g + ', ' + this._color.b + ', 0.8)'; - this._game.stage.context.fill(); - this._game.stage.context.closePath(); + this.game.stage.context.beginPath(); + this.game.stage.context.moveTo(sx, sy); + this.game.stage.context.lineTo(sx, sy + arrowHeight); + this.game.stage.context.lineTo(sx + arrowWidth, this.game.stage.centerY); + this.game.stage.context.fillStyle = 'rgba(' + this._color.r + ', ' + this._color.g + ', ' + this._color.b + ', 0.8)'; + this.game.stage.context.fill(); + this.game.stage.context.closePath(); } @@ -117,7 +117,7 @@ module Phaser { */ private fadeOut() { - this._fade = this._game.add.tween(this._color); + this._fade = this.game.add.tween(this._color); this._fade.to({ r: 50, g: 50, b: 50 }, 1000, Phaser.Easing.Linear.None); this._fade.onComplete.add(this.fadeIn, this); @@ -130,7 +130,7 @@ module Phaser { */ private fadeIn() { - this._fade = this._game.add.tween(this._color); + this._fade = this.game.add.tween(this._color); this._fade.to({ r: 255, g: 255, b: 255 }, 1000, Phaser.Easing.Linear.None); this._fade.onComplete.add(this.fadeOut, this); diff --git a/Phaser/tilemap/Tile.ts b/Phaser/tilemap/Tile.ts index d7c4cb88..514aeba9 100644 --- a/Phaser/tilemap/Tile.ts +++ b/Phaser/tilemap/Tile.ts @@ -21,7 +21,7 @@ module Phaser { */ constructor(game: Game, tilemap: Tilemap, index: number, width: number, height: number) { - this._game = game; + this.game = game; this.tilemap = tilemap; this.index = index; @@ -32,9 +32,9 @@ module Phaser { } /** - * Local private reference to game. + * Local reference to Game. */ - private _game: Game; + public game: Game; /** * You can give this Tile a friendly name to help with debugging. Never used internally. diff --git a/Phaser/tilemap/TilemapLayer.ts b/Phaser/tilemap/TilemapLayer.ts index 28beb84a..6bf0f117 100644 --- a/Phaser/tilemap/TilemapLayer.ts +++ b/Phaser/tilemap/TilemapLayer.ts @@ -64,7 +64,7 @@ module Phaser { private _tempBlockResults; /** - * Local private reference to game. + * Local reference to Game. */ public game: Game; diff --git a/Phaser/tweens/Tween.ts b/Phaser/tweens/Tween.ts index 05b2dd8d..7a911a72 100644 --- a/Phaser/tweens/Tween.ts +++ b/Phaser/tweens/Tween.ts @@ -32,9 +32,9 @@ module Phaser { this._object = object; - this._game = game; - this._manager = this._game.tweens; - this._interpolationFunction = this._game.math.linearInterpolation; + this.game = game; + this._manager = this.game.tweens; + this._interpolationFunction = this.game.math.linearInterpolation; this._easingFunction = Phaser.Easing.Linear.None; this._chainedTweens = []; @@ -45,9 +45,9 @@ module Phaser { } /** - * Local private reference to game. + * Local reference to Game. */ - private _game: Phaser.Game; + public game: Phaser.Game; /** * Manager of this tween. @@ -194,7 +194,7 @@ module Phaser { */ public start(looped: bool = false): Tween { - if (this._game === null || this._object === null) + if (this.game === null || this._object === null) { return; } @@ -206,7 +206,7 @@ module Phaser { this.onStart.dispatch(this._object); } - this._startTime = this._game.time.now + this._delayTime; + this._startTime = this.game.time.now + this._delayTime; this.isRunning = true; for (var property in this._valuesEnd) @@ -302,8 +302,8 @@ module Phaser { public set parent(value:Phaser.Game) { - this._game = value; - this._manager = this._game.tweens; + this.game = value; + this._manager = this.game.tweens; } @@ -351,7 +351,7 @@ module Phaser { */ public update(time) { - if (this._game.paused == true) + if (this.game.paused == true) { if (this._pausedTime == 0) { diff --git a/Phaser/tweens/TweenManager.ts b/Phaser/tweens/TweenManager.ts index 9430cd1a..43013435 100644 --- a/Phaser/tweens/TweenManager.ts +++ b/Phaser/tweens/TweenManager.ts @@ -21,15 +21,15 @@ module Phaser { */ constructor(game: Phaser.Game) { - this._game = game; + this.game = game; this._tweens = []; } /** - * Local private reference to Game + * Local reference to Game */ - private _game: Phaser.Game; + public game: Phaser.Game; /** * Local private array which is the container of all tween objects. @@ -66,12 +66,12 @@ module Phaser { if (localReference) { - object['tween'] = new Phaser.Tween(object, this._game); + object['tween'] = new Phaser.Tween(object, this.game); return object['tween']; } else { - return new Phaser.Tween(object, this._game); + return new Phaser.Tween(object, this.game); } } @@ -84,7 +84,7 @@ module Phaser { */ public add(tween: Phaser.Tween) { - tween.parent = this._game; + tween.parent = this.game; this._tweens.push(tween); @@ -125,7 +125,7 @@ module Phaser { while (i < numTweens) { - if (this._tweens[i].update(this._game.time.now)) + if (this._tweens[i].update(this.game.time.now)) { i++; } diff --git a/Phaser/utils/SpriteUtils.ts b/Phaser/utils/SpriteUtils.ts index 3ded1d44..07b295c1 100644 --- a/Phaser/utils/SpriteUtils.ts +++ b/Phaser/utils/SpriteUtils.ts @@ -131,7 +131,7 @@ module Phaser { if (camera == null) { - camera = this._game.camera; + camera = this.game.camera; } var objectScreenPos: Point = objectOrGroup.getScreenXY(null, camera); @@ -236,7 +236,7 @@ module Phaser { if (camera == null) { - camera = this._game.camera; + camera = this.game.camera; } point.x = sprite.x - camera.x * sprite.transform.scrollFactor.x; @@ -256,7 +256,7 @@ module Phaser { /* static setBoundsFromWorld(action?: number = GameObject.OUT_OF_BOUNDS_STOP) { - this.setBounds(this._game.world.bounds.x, this._game.world.bounds.y, this._game.world.bounds.width, this._game.world.bounds.height); + this.setBounds(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height); this.outOfBoundsAction = action; } diff --git a/README.md b/README.md index 0e9b95ae..7cab5971 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,12 @@ Try out the [Phaser Test Suite](http://gametest.mobi/phaser/) "Being negative is not how we make progress" - Larry Page, Google +Known Issues +------------ + +* Input detection on Sprites/Buttons doesn't work if the CAMERA is rotated or scaled. + + Latest Update ------------- @@ -25,7 +31,7 @@ TODO: * Inject game into a
* Add ability to create extra
s within the game container, layered above/below the canvas * Rename init to preload and call start automatically -* Poll the Input handlers less frequently (every other frame?) +* Allow camera to directly render to the stage rather than its hidden (maybe does this by default? or have under Mobile Optimisations list) @@ -158,7 +164,8 @@ V1.0.0 * Fixed interesting Firefox issue when an audio track ended it fired another 'canplaythrough' event, confusing the Loader. * Added the new PluginManager. Moved all the Camera FX over to plugins. Everything will be a plugin from now on. * Added Sprite.transform.centerOn(x,y) to quickly center a sprite on a coordinate without messing with the sprite origin and regardless of rotation. - +* Added Input.pollRate - this lets you limit how often Pointer events are handled (0 = every frame, 1 = every other frame, etc) +* Renamed the 'init' function to 'preload' and now call load.start automatically. V0.9.6 diff --git a/Tests/audio/audio sprites 1.js b/Tests/audio/audio sprites 1.js index 475fbf4c..d7387a0a 100644 --- a/Tests/audio/audio sprites 1.js +++ b/Tests/audio/audio sprites 1.js @@ -3,15 +3,14 @@ /// //var PhaserGlobal = { disableWebAudio: true }; (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { game.load.audio('rabbit', [ 'assets/mp3/peter_rabbit.m4a', 'assets/mp3/peter_rabbit.mp3', 'assets/mp3/peter_rabbit.ogg' ]); game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71); - game.load.start(); } audioSprite: Phaser.Sound diff --git a/Tests/audio/audio sprites 1.ts b/Tests/audio/audio sprites 1.ts index bd6b6e33..71828853 100644 --- a/Tests/audio/audio sprites 1.ts +++ b/Tests/audio/audio sprites 1.ts @@ -6,13 +6,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { game.load.audio('rabbit', ['assets/mp3/peter_rabbit.m4a', 'assets/mp3/peter_rabbit.mp3', 'assets/mp3/peter_rabbit.ogg']); game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71); - game.load.start(); + } diff --git a/Tests/audio/play sound 1.js b/Tests/audio/play sound 1.js index 0b289bf3..ab73325c 100644 --- a/Tests/audio/play sound 1.js +++ b/Tests/audio/play sound 1.js @@ -3,14 +3,13 @@ /// //var PhaserGlobal = { fakeiOSTouchLock: true, disableWebAudio: true }; (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { //game.load.audio('wizball', ['assets/mp3/oedipus_wizball_highscore.ogg', 'assets/mp3/oedipus_wizball_highscore.mp3']); game.load.audio('boden', [ 'assets/mp3/bodenstaendig_2000_in_rock_4bit.mp3' ]); game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71); - game.load.start(); } button: Phaser.UI.Button diff --git a/Tests/audio/play sound 1.ts b/Tests/audio/play sound 1.ts index d7035395..e51443a3 100644 --- a/Tests/audio/play sound 1.ts +++ b/Tests/audio/play sound 1.ts @@ -6,14 +6,14 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { //game.load.audio('wizball', ['assets/mp3/oedipus_wizball_highscore.ogg', 'assets/mp3/oedipus_wizball_highscore.mp3']); game.load.audio('boden', ['assets/mp3/bodenstaendig_2000_in_rock_4bit.mp3']); game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71); - game.load.start(); + } diff --git a/Tests/buttons/basic button 2.js b/Tests/buttons/basic button 2.js index 7c1914f1..61fbe23a 100644 --- a/Tests/buttons/basic button 2.js +++ b/Tests/buttons/basic button 2.js @@ -1,11 +1,10 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png'); game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json'); - game.load.start(); } image: Phaser.Sprite diff --git a/Tests/buttons/basic button 2.ts b/Tests/buttons/basic button 2.ts index cc75f0d4..7d15f7fe 100644 --- a/Tests/buttons/basic button 2.ts +++ b/Tests/buttons/basic button 2.ts @@ -3,13 +3,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png'); game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json'); - game.load.start(); + } diff --git a/Tests/buttons/basic button.js b/Tests/buttons/basic button.js index a332e884..e523c871 100644 --- a/Tests/buttons/basic button.js +++ b/Tests/buttons/basic button.js @@ -1,11 +1,10 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png'); game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71); - game.load.start(); } image: Phaser.Sprite diff --git a/Tests/buttons/basic button.ts b/Tests/buttons/basic button.ts index da10ee93..7155b823 100644 --- a/Tests/buttons/basic button.ts +++ b/Tests/buttons/basic button.ts @@ -3,13 +3,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png'); game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71); - game.load.start(); + } diff --git a/Tests/buttons/camera buttons.js b/Tests/buttons/camera buttons.js index 493704bd..e4b4666f 100644 --- a/Tests/buttons/camera buttons.js +++ b/Tests/buttons/camera buttons.js @@ -1,10 +1,9 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71); - game.load.start(); } var button; var secondCam; diff --git a/Tests/buttons/camera buttons.ts b/Tests/buttons/camera buttons.ts index 38018be6..788fd8ba 100644 --- a/Tests/buttons/camera buttons.ts +++ b/Tests/buttons/camera buttons.ts @@ -3,12 +3,12 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71); - game.load.start(); + } diff --git a/Tests/buttons/rotated buttons.js b/Tests/buttons/rotated buttons.js index 00459f43..64d967de 100644 --- a/Tests/buttons/rotated buttons.js +++ b/Tests/buttons/rotated buttons.js @@ -1,11 +1,10 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png'); game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json'); - game.load.start(); } image: Phaser.Sprite diff --git a/Tests/buttons/rotated buttons.ts b/Tests/buttons/rotated buttons.ts index 39a788b9..64914bf4 100644 --- a/Tests/buttons/rotated buttons.ts +++ b/Tests/buttons/rotated buttons.ts @@ -3,13 +3,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png'); game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json'); - game.load.start(); + } diff --git a/Tests/camera fx/mirror.js b/Tests/camera fx/mirror.js index a4ec965f..ca47ce14 100644 --- a/Tests/camera fx/mirror.js +++ b/Tests/camera fx/mirror.js @@ -1,10 +1,9 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.image('backdrop', 'assets/pics/ninja-masters2.png'); - game.load.start(); } var mirror; function create() { diff --git a/Tests/camera fx/mirror.ts b/Tests/camera fx/mirror.ts index c1a0ca0a..7292168d 100644 --- a/Tests/camera fx/mirror.ts +++ b/Tests/camera fx/mirror.ts @@ -3,13 +3,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.image('backdrop', 'assets/pics/ninja-masters2.png'); - game.load.start(); + } diff --git a/Tests/camera fx/scanlines.js b/Tests/camera fx/scanlines.js index bd3738d1..f0f3faf1 100644 --- a/Tests/camera fx/scanlines.js +++ b/Tests/camera fx/scanlines.js @@ -1,10 +1,9 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.image('backdrop', 'assets/pics/ninja-masters2.png'); - game.load.start(); } var scanlines; function create() { diff --git a/Tests/camera fx/scanlines.ts b/Tests/camera fx/scanlines.ts index 7e531549..8dff7678 100644 --- a/Tests/camera fx/scanlines.ts +++ b/Tests/camera fx/scanlines.ts @@ -3,13 +3,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.image('backdrop', 'assets/pics/ninja-masters2.png'); - game.load.start(); + } diff --git a/Tests/cameras/basic camera 1.js b/Tests/cameras/basic camera 1.js index 47778f9f..65e10e62 100644 --- a/Tests/cameras/basic camera 1.js +++ b/Tests/cameras/basic camera 1.js @@ -1,13 +1,12 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { - game.world.setSize(1920, 1200, true); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); game.load.image('melon', 'assets/sprites/melon.png'); - game.load.start(); } function create() { + game.world.setSize(1920, 1200, true); game.add.sprite(0, 0, 'backdrop'); for(var i = 0; i < 100; i++) { game.add.sprite(game.world.randomX, game.world.randomY, 'melon'); diff --git a/Tests/cameras/basic camera 1.ts b/Tests/cameras/basic camera 1.ts index 3b5e5c69..ed941ec9 100644 --- a/Tests/cameras/basic camera 1.ts +++ b/Tests/cameras/basic camera 1.ts @@ -2,21 +2,19 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { - - game.world.setSize(1920, 1200, true); + function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); game.load.image('melon', 'assets/sprites/melon.png'); - game.load.start(); - } function create() { + game.world.setSize(1920, 1200, true); + game.add.sprite(0, 0, 'backdrop'); for (var i = 0; i < 100; i++) diff --git a/Tests/cameras/basic follow.js b/Tests/cameras/basic follow.js index 24a217f3..76b3df86 100644 --- a/Tests/cameras/basic follow.js +++ b/Tests/cameras/basic follow.js @@ -1,9 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); var ufo; var speed = 4; - function init() { + function preload() { game.world.setSize(1280, 600, true); game.load.image('ground', 'assets/tests/ground-2x.png'); game.load.image('river', 'assets/tests/river-2x.png'); @@ -12,7 +12,6 @@ game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png'); game.load.image('cloud2', 'assets/tests/cloud-small-2x.png'); game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21); - game.load.start(); } function create() { // background images diff --git a/Tests/cameras/basic follow.ts b/Tests/cameras/basic follow.ts index 2b1187fc..6567bee3 100644 --- a/Tests/cameras/basic follow.ts +++ b/Tests/cameras/basic follow.ts @@ -1,11 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); var ufo: Phaser.Sprite; var speed: number = 4; - function init() { + function preload() { game.world.setSize(1280, 600, true); game.load.image('ground', 'assets/tests/ground-2x.png'); game.load.image('river', 'assets/tests/river-2x.png'); @@ -16,7 +16,7 @@ game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21); - game.load.start(); + } function create() { // background images diff --git a/Tests/cameras/camera alpha.js b/Tests/cameras/camera alpha.js index 24ef08aa..c6fc4a66 100644 --- a/Tests/cameras/camera alpha.js +++ b/Tests/cameras/camera alpha.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png'); game.load.image('car', 'assets/sprites/car90.png'); - game.load.start(); } var car; var miniCam; diff --git a/Tests/cameras/camera alpha.ts b/Tests/cameras/camera alpha.ts index ce37b414..0051eb8b 100644 --- a/Tests/cameras/camera alpha.ts +++ b/Tests/cameras/camera alpha.ts @@ -2,14 +2,14 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png'); game.load.image('car', 'assets/sprites/car90.png'); - game.load.start(); + } diff --git a/Tests/cameras/camera fx 1.js b/Tests/cameras/camera fx 1.js index 10aaba44..a8260d2b 100644 --- a/Tests/cameras/camera fx 1.js +++ b/Tests/cameras/camera fx 1.js @@ -1,14 +1,13 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var btn1, btn2, btn3; var fx; - function init() { + function preload() { game.world.setSize(800, 600, true); game.load.image('blue', 'assets/tests/blue-circle.png'); game.load.image('yellow', 'assets/tests/yellow-circle.png'); game.load.image('magenta', 'assets/tests/magenta-circle.png'); - game.load.start(); } function create() { btn1 = game.add.button(114, 34, 'blue', simpleFade, this); diff --git a/Tests/cameras/camera fx 1.ts b/Tests/cameras/camera fx 1.ts index 1af3d70d..b228bf27 100644 --- a/Tests/cameras/camera fx 1.ts +++ b/Tests/cameras/camera fx 1.ts @@ -1,19 +1,19 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var btn1: Phaser.UI.Button, btn2: Phaser.UI.Button, btn3: Phaser.UI.Button; var fx; - function init() { + function preload() { game.world.setSize(800, 600, true); game.load.image('blue', 'assets/tests/blue-circle.png'); game.load.image('yellow', 'assets/tests/yellow-circle.png'); game.load.image('magenta', 'assets/tests/magenta-circle.png'); - game.load.start(); + } function create() { btn1 = game.add.button(114, 34, 'blue', simpleFade, this); diff --git a/Tests/cameras/camera fx 2.js b/Tests/cameras/camera fx 2.js index 37338163..d8f3a480 100644 --- a/Tests/cameras/camera fx 2.js +++ b/Tests/cameras/camera fx 2.js @@ -1,14 +1,13 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var btn1, btn2, btn3; var fx; - function init() { + function preload() { game.world.setSize(800, 600, true); game.load.image('blue', 'assets/tests/blue-circle.png'); game.load.image('yellow', 'assets/tests/yellow-circle.png'); game.load.image('magenta', 'assets/tests/magenta-circle.png'); - game.load.start(); } function create() { btn1 = game.add.button(114, 34, 'blue', simpleFlash, this); diff --git a/Tests/cameras/camera fx 2.ts b/Tests/cameras/camera fx 2.ts index 4bc11687..197350e6 100644 --- a/Tests/cameras/camera fx 2.ts +++ b/Tests/cameras/camera fx 2.ts @@ -1,19 +1,19 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var btn1: Phaser.UI.Button, btn2: Phaser.UI.Button, btn3: Phaser.UI.Button; var fx; - function init() { + function preload() { game.world.setSize(800, 600, true); game.load.image('blue', 'assets/tests/blue-circle.png'); game.load.image('yellow', 'assets/tests/yellow-circle.png'); game.load.image('magenta', 'assets/tests/magenta-circle.png'); - game.load.start(); + } function create() { btn1 = game.add.button(114, 34, 'blue', simpleFlash, this); diff --git a/Tests/cameras/camera fx 3.js b/Tests/cameras/camera fx 3.js index ffb32d51..989f8d86 100644 --- a/Tests/cameras/camera fx 3.js +++ b/Tests/cameras/camera fx 3.js @@ -1,14 +1,13 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var btn1, btn2, btn3; var fx; - function init() { + function preload() { game.world.setSize(800, 600, true); game.load.image('blue', 'assets/tests/blue-circle.png'); game.load.image('yellow', 'assets/tests/yellow-circle.png'); game.load.image('magenta', 'assets/tests/magenta-circle.png'); - game.load.start(); } function create() { btn1 = game.add.button(114, 34, 'blue', simpleShake, this); diff --git a/Tests/cameras/camera fx 3.ts b/Tests/cameras/camera fx 3.ts index 770a0c51..0ab7a3b7 100644 --- a/Tests/cameras/camera fx 3.ts +++ b/Tests/cameras/camera fx 3.ts @@ -1,19 +1,19 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var btn1: Phaser.UI.Button, btn2: Phaser.UI.Button, btn3: Phaser.UI.Button; var fx; - function init() { + function preload() { game.world.setSize(800, 600, true); game.load.image('blue', 'assets/tests/blue-circle.png'); game.load.image('yellow', 'assets/tests/yellow-circle.png'); game.load.image('magenta', 'assets/tests/magenta-circle.png'); - game.load.start(); + } function create() { btn1 = game.add.button(114, 34, 'blue', simpleShake, this); diff --git a/Tests/cameras/camera rotation.js b/Tests/cameras/camera rotation.js index 222e213e..8a81cf3c 100644 --- a/Tests/cameras/camera rotation.js +++ b/Tests/cameras/camera rotation.js @@ -1,9 +1,8 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.load.image('melon', 'assets/sprites/melon.png'); - game.load.start(); } var car; var miniCam; diff --git a/Tests/cameras/camera rotation.ts b/Tests/cameras/camera rotation.ts index 3514d7a3..b2c916c5 100644 --- a/Tests/cameras/camera rotation.ts +++ b/Tests/cameras/camera rotation.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.load.image('melon', 'assets/sprites/melon.png'); - game.load.start(); + } diff --git a/Tests/cameras/camera scale.js b/Tests/cameras/camera scale.js index 36a73b63..fa0b4b60 100644 --- a/Tests/cameras/camera scale.js +++ b/Tests/cameras/camera scale.js @@ -1,16 +1,15 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var zombieCamera; var zombie; var walkSpeed = 2, direction = 1; - function init() { + function preload() { game.world.setSize(1280, 600, true); game.load.image('ground', 'assets/tests/ground-2x.png'); game.load.image('river', 'assets/tests/river-2x.png'); game.load.image('sky', 'assets/tests/sky-2x.png'); game.load.spritesheet('zombie', 'assets/sprites/metalslug_monster39x40.png', 39, 40); - game.load.start(); } function create() { // Add background images. diff --git a/Tests/cameras/camera scale.ts b/Tests/cameras/camera scale.ts index d4314f50..8254f2f0 100644 --- a/Tests/cameras/camera scale.ts +++ b/Tests/cameras/camera scale.ts @@ -1,6 +1,6 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var zombieCamera: Phaser.Camera; @@ -8,7 +8,7 @@ var walkSpeed: number = 2, direction: number = 1; - function init() { + function preload() { game.world.setSize(1280, 600, true); game.load.image('ground', 'assets/tests/ground-2x.png'); game.load.image('river', 'assets/tests/river-2x.png'); @@ -16,7 +16,7 @@ game.load.spritesheet('zombie', 'assets/sprites/metalslug_monster39x40.png', 39, 40); - game.load.start(); + } function create() { // Add background images. diff --git a/Tests/cameras/camera texture.js b/Tests/cameras/camera texture.js index 5595890b..a84f408a 100644 --- a/Tests/cameras/camera texture.js +++ b/Tests/cameras/camera texture.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { game.world.setSize(800, 600, true); game.load.image('background', 'assets/misc/water_texture.jpg'); - game.load.start(); } function create() { game.camera.texture.loadImage('background', false); diff --git a/Tests/cameras/camera texture.ts b/Tests/cameras/camera texture.ts index 5a95701a..2e092c9e 100644 --- a/Tests/cameras/camera texture.ts +++ b/Tests/cameras/camera texture.ts @@ -1,12 +1,12 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { game.world.setSize(800, 600, true); game.load.image('background', 'assets/misc/water_texture.jpg'); - game.load.start(); + } function create() { game.camera.texture.loadImage('background', false); diff --git a/Tests/cameras/follow styles.js b/Tests/cameras/follow styles.js index 65ff5a7c..88a59aa1 100644 --- a/Tests/cameras/follow styles.js +++ b/Tests/cameras/follow styles.js @@ -1,10 +1,10 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var ufo, speed = 4; var btn0, btn1, btn2, btn3; var style = 'default'; - function init() { + function preload() { game.world.setSize(1280, 800, true); game.load.image('ground', 'assets/tests/ground-2x.png'); game.load.image('river', 'assets/tests/river-2x.png'); @@ -14,7 +14,6 @@ game.load.image('cloud2', 'assets/tests/cloud-small-2x.png'); game.load.spritesheet('button', 'assets/buttons/follow-style-button.png', 224, 70); game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21); - game.load.start(); } function create() { // background images diff --git a/Tests/cameras/follow styles.ts b/Tests/cameras/follow styles.ts index bd9df4d1..fda27733 100644 --- a/Tests/cameras/follow styles.ts +++ b/Tests/cameras/follow styles.ts @@ -1,6 +1,6 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var ufo: Phaser.Sprite, speed: number = 4; @@ -11,7 +11,7 @@ btn3: Phaser.UI.Button; var style: string = 'default'; - function init() { + function preload() { game.world.setSize(1280, 800, true); game.load.image('ground', 'assets/tests/ground-2x.png'); game.load.image('river', 'assets/tests/river-2x.png'); @@ -24,7 +24,7 @@ game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21); - game.load.start(); + } function create() { // background images diff --git a/Tests/cameras/hide from camera.js b/Tests/cameras/hide from camera.js index b330fef3..fabbd81f 100644 --- a/Tests/cameras/hide from camera.js +++ b/Tests/cameras/hide from camera.js @@ -1,14 +1,13 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var radar; var ships = []; var enemyCamera; - function init() { + function preload() { game.load.image('radar-surface', 'assets/tests/radar-surface.png'); game.load.image('ship', 'assets/sprites/asteroids_ship_white.png'); game.load.image('enemy-ship', 'assets/sprites/asteroids_ship.png'); - game.load.start(); } function create() { // Add enemies and our ship the the world. diff --git a/Tests/cameras/hide from camera.ts b/Tests/cameras/hide from camera.ts index 5155994a..6570e476 100644 --- a/Tests/cameras/hide from camera.ts +++ b/Tests/cameras/hide from camera.ts @@ -1,20 +1,20 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var radar: Phaser.Sprite; var ships: Phaser.Sprite[] = []; var enemyCamera: Phaser.Camera; - function init() { + function preload() { game.load.image('radar-surface', 'assets/tests/radar-surface.png'); game.load.image('ship', 'assets/sprites/asteroids_ship_white.png'); game.load.image('enemy-ship', 'assets/sprites/asteroids_ship.png'); - game.load.start(); + } function create() { diff --git a/Tests/cameras/multi camera.js b/Tests/cameras/multi camera.js index 2b1ce94d..ecaf01ff 100644 --- a/Tests/cameras/multi camera.js +++ b/Tests/cameras/multi camera.js @@ -1,16 +1,15 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var zombieCamera; var zombie; var walkSpeed = 2, direction = 1; - function init() { + function preload() { game.world.setSize(1280, 600, true); game.load.image('ground', 'assets/tests/ground-2x.png'); game.load.image('river', 'assets/tests/river-2x.png'); game.load.image('sky', 'assets/tests/sky-2x.png'); game.load.spritesheet('zombie', 'assets/sprites/metalslug_monster39x40.png', 39, 40); - game.load.start(); } function create() { // Add background images. diff --git a/Tests/cameras/multi camera.ts b/Tests/cameras/multi camera.ts index e3adbe3c..93b38f52 100644 --- a/Tests/cameras/multi camera.ts +++ b/Tests/cameras/multi camera.ts @@ -1,6 +1,6 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var zombieCamera: Phaser.Camera; @@ -8,7 +8,7 @@ var walkSpeed: number = 2, direction: number = 1; - function init() { + function preload() { game.world.setSize(1280, 600, true); game.load.image('ground', 'assets/tests/ground-2x.png'); game.load.image('river', 'assets/tests/river-2x.png'); @@ -16,7 +16,7 @@ game.load.spritesheet('zombie', 'assets/sprites/metalslug_monster39x40.png', 39, 40); - game.load.start(); + } function create() { // Add background images. diff --git a/Tests/cameras/scrollfactor 1.js b/Tests/cameras/scrollfactor 1.js index bf8a7986..9f5ee199 100644 --- a/Tests/cameras/scrollfactor 1.js +++ b/Tests/cameras/scrollfactor 1.js @@ -1,11 +1,10 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.world.setSize(1920, 1200, true); game.load.image('backdrop', 'assets/pics/remember-me.jpg'); game.load.image('ball', 'assets/sprites/shinyball.png'); - game.load.start(); } function create() { game.add.sprite(0, 0, 'backdrop'); diff --git a/Tests/cameras/scrollfactor 1.ts b/Tests/cameras/scrollfactor 1.ts index c9921c76..82217633 100644 --- a/Tests/cameras/scrollfactor 1.ts +++ b/Tests/cameras/scrollfactor 1.ts @@ -2,16 +2,16 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.world.setSize(1920, 1200, true); game.load.image('backdrop', 'assets/pics/remember-me.jpg'); game.load.image('ball', 'assets/sprites/shinyball.png'); - game.load.start(); + } diff --git a/Tests/cameras/scrollfactor 2.js b/Tests/cameras/scrollfactor 2.js index b8c96a72..bcb5b569 100644 --- a/Tests/cameras/scrollfactor 2.js +++ b/Tests/cameras/scrollfactor 2.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.world.setSize(1600, 800, true); game.load.image('disk', 'assets/pics/devilstar_demo_download_disk.png'); - game.load.start(); } function create() { for(var i = 0; i < 10; i++) { diff --git a/Tests/cameras/scrollfactor 2.ts b/Tests/cameras/scrollfactor 2.ts index b0f40d13..c97093b2 100644 --- a/Tests/cameras/scrollfactor 2.ts +++ b/Tests/cameras/scrollfactor 2.ts @@ -2,15 +2,15 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.world.setSize(1600, 800, true); game.load.image('disk', 'assets/pics/devilstar_demo_download_disk.png'); - game.load.start(); + } diff --git a/Tests/cameras/scrollfactor compare.js b/Tests/cameras/scrollfactor compare.js index f0b2ba98..8cd2b944 100644 --- a/Tests/cameras/scrollfactor compare.js +++ b/Tests/cameras/scrollfactor compare.js @@ -1,7 +1,7 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.world.setSize(1280, 600, true); game.load.image('ground', 'assets/tests/ground-2x.png'); game.load.image('river', 'assets/tests/river-2x.png'); @@ -9,7 +9,6 @@ game.load.image('cloud0', 'assets/tests/cloud-big-2x.png'); game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png'); game.load.image('cloud2', 'assets/tests/cloud-small-2x.png'); - game.load.start(); } function create() { // background sky, which does not move at all diff --git a/Tests/cameras/scrollfactor compare.ts b/Tests/cameras/scrollfactor compare.ts index 07b499a1..7ceab175 100644 --- a/Tests/cameras/scrollfactor compare.ts +++ b/Tests/cameras/scrollfactor compare.ts @@ -1,7 +1,7 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.world.setSize(1280, 600, true); game.load.image('ground', 'assets/tests/ground-2x.png'); game.load.image('river', 'assets/tests/river-2x.png'); @@ -9,7 +9,7 @@ game.load.image('cloud0', 'assets/tests/cloud-big-2x.png'); game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png'); game.load.image('cloud2', 'assets/tests/cloud-small-2x.png'); - game.load.start(); + } function create() { // background sky, which does not move at all diff --git a/Tests/cameras/world sprite.js b/Tests/cameras/world sprite.js index 699efb8e..79c45b75 100644 --- a/Tests/cameras/world sprite.js +++ b/Tests/cameras/world sprite.js @@ -1,12 +1,11 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.world.setSize(1920, 1200, true); game.load.image('backdrop', 'assets/pics/remember-me.jpg'); game.load.image('ball', 'assets/sprites/mana_card.png'); - game.load.start(); } var ball; function create() { diff --git a/Tests/cameras/world sprite.ts b/Tests/cameras/world sprite.ts index 5036638f..ec79dc37 100644 --- a/Tests/cameras/world sprite.ts +++ b/Tests/cameras/world sprite.ts @@ -3,16 +3,16 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.world.setSize(1920, 1200, true); game.load.image('backdrop', 'assets/pics/remember-me.jpg'); game.load.image('ball', 'assets/sprites/mana_card.png'); - game.load.start(); + } diff --git a/Tests/groups/add to group 1.ts b/Tests/groups/add to group 1.ts index 58cc89b9..1b85986f 100644 --- a/Tests/groups/add to group 1.ts +++ b/Tests/groups/add to group 1.ts @@ -1,14 +1,14 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var friendAndFoe: Phaser.Group, enemies: Phaser.Group; - function init() { + function preload() { game.load.image('ufo', 'assets/sprites/ufo.png'); game.load.image('baddie', 'assets/sprites/space-baddie.png'); - game.load.start(); + } function create() { // Create some local groups for later use. diff --git a/Tests/groups/add to group 2.ts b/Tests/groups/add to group 2.ts index 25b8da0f..d5e74de2 100644 --- a/Tests/groups/add to group 2.ts +++ b/Tests/groups/add to group 2.ts @@ -1,10 +1,10 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { game.load.image('ufo', 'assets/sprites/ufo.png'); game.load.image('baddie', 'assets/sprites/space-baddie.png'); - game.load.start(); + } var friendAndFoe: Phaser.Group, diff --git a/Tests/groups/bring to top 1.js b/Tests/groups/bring to top 1.js index 475bd977..1c04b58f 100644 --- a/Tests/groups/bring to top 1.js +++ b/Tests/groups/bring to top 1.js @@ -1,14 +1,13 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png'); game.load.image('snot', 'assets/pics/nslide_snot.png'); game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png'); game.load.image('coke', 'assets/sprites/cokecan.png'); game.load.image('disk', 'assets/sprites/oz_pov_melting_disk.png'); - game.load.start(); } var group1; var group2; diff --git a/Tests/groups/bring to top 1.ts b/Tests/groups/bring to top 1.ts index fa9e7743..28cb07a9 100644 --- a/Tests/groups/bring to top 1.ts +++ b/Tests/groups/bring to top 1.ts @@ -2,9 +2,9 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png'); game.load.image('snot', 'assets/pics/nslide_snot.png'); @@ -12,7 +12,7 @@ game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png'); game.load.image('coke', 'assets/sprites/cokecan.png'); game.load.image('disk', 'assets/sprites/oz_pov_melting_disk.png'); - game.load.start(); + } diff --git a/Tests/groups/bring to top.ts b/Tests/groups/bring to top.ts index 4521e954..658497c3 100644 --- a/Tests/groups/bring to top.ts +++ b/Tests/groups/bring to top.ts @@ -1,11 +1,11 @@ (function() { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var container: Phaser.Group; - function init() { + function preload() { game.load.spritesheet('button', 'assets/buttons/number-buttons.png', 160, 160); - game.load.start(); + } function create() { // Container for sorting the buttons, which we'll use to make buttons diff --git a/Tests/groups/call all.ts b/Tests/groups/call all.ts index e8f5997a..530b4eeb 100644 --- a/Tests/groups/call all.ts +++ b/Tests/groups/call all.ts @@ -1,11 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90); game.load.image('reviveBtn', 'assets/buttons/revive-button.png'); - game.load.start(); + } function create() { // Add some items. diff --git a/Tests/groups/create group 1.js b/Tests/groups/create group 1.js index 3c52681f..893a3208 100644 --- a/Tests/groups/create group 1.js +++ b/Tests/groups/create group 1.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png'); - game.load.start(); } var firstGroup; function create() { diff --git a/Tests/groups/create group 1.ts b/Tests/groups/create group 1.ts index d0970c61..7e2e71bc 100644 --- a/Tests/groups/create group 1.ts +++ b/Tests/groups/create group 1.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png'); - game.load.start(); + } diff --git a/Tests/groups/direct render.ts b/Tests/groups/direct render.ts index 3216fad3..10d03b95 100644 --- a/Tests/groups/direct render.ts +++ b/Tests/groups/direct render.ts @@ -1,15 +1,15 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); // Left and right group. var left:: Phaser.Group, right: Phaser.Group; // The first selected item. var selected: Phaser.Sprite = null; - function init() { + function preload() { game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90); - game.load.start(); + } function create() { left = game.add.group(); diff --git a/Tests/groups/display order.js b/Tests/groups/display order.js index db0cc529..cf537b60 100644 --- a/Tests/groups/display order.js +++ b/Tests/groups/display order.js @@ -1,11 +1,10 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('atari2', 'assets/sprites/atari800xl.png'); game.load.image('card', 'assets/sprites/mana_card.png'); - game.load.start(); } var items; var card; diff --git a/Tests/groups/display order.ts b/Tests/groups/display order.ts index 609282d0..3795e3e9 100644 --- a/Tests/groups/display order.ts +++ b/Tests/groups/display order.ts @@ -2,15 +2,15 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('atari2', 'assets/sprites/atari800xl.png'); game.load.image('card', 'assets/sprites/mana_card.png'); - game.load.start(); + } diff --git a/Tests/groups/for each.ts b/Tests/groups/for each.ts index c24f1506..f41e5aaa 100644 --- a/Tests/groups/for each.ts +++ b/Tests/groups/for each.ts @@ -1,12 +1,12 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var baseAlphaIncSpeed: Number = 0.006; - function init() { + function preload() { game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90); - game.load.start(); + } function create() { // Add some items. diff --git a/Tests/groups/get first 1.ts b/Tests/groups/get first 1.ts index 818d19d4..5ef8194e 100644 --- a/Tests/groups/get first 1.ts +++ b/Tests/groups/get first 1.ts @@ -1,14 +1,14 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var timer: Number, cycle: Number; - function init() { + function preload() { game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90); game.load.image('reviveBtn', 'assets/buttons/revive-button.png'); - game.load.start(); + } function create() { // Add some items. diff --git a/Tests/groups/get first 2.ts b/Tests/groups/get first 2.ts index 137fba29..dc61445a 100644 --- a/Tests/groups/get first 2.ts +++ b/Tests/groups/get first 2.ts @@ -1,14 +1,14 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var timer: Number, cycle: Number; - function init() { + function preload() { game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90); game.load.image('reviveBtn', 'assets/buttons/revive-button.png'); - game.load.start(); + } function create() { // Add some items. diff --git a/Tests/groups/get first 3.ts b/Tests/groups/get first 3.ts index db588a43..cfc69653 100644 --- a/Tests/groups/get first 3.ts +++ b/Tests/groups/get first 3.ts @@ -1,15 +1,15 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var killTimer: Number, reviveTimer: Number, cycle: Number; - function init() { + function preload() { game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90); game.load.image('reviveBtn', 'assets/buttons/revive-button.png'); - game.load.start(); + } function create() { // Add some items. diff --git a/Tests/groups/group as layer.ts b/Tests/groups/group as layer.ts index 31a802cb..1c221822 100644 --- a/Tests/groups/group as layer.ts +++ b/Tests/groups/group as layer.ts @@ -1,7 +1,7 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { game.world.setSize(1280, 800, true); game.load.image('ground', 'assets/tests/ground-2x.png'); @@ -13,7 +13,7 @@ game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21); - game.load.start(); + } function create() { // Create the sky layer, behind everything and donot move. diff --git a/Tests/groups/group transform 1.ts b/Tests/groups/group transform 1.ts index 7bc02ebb..0166e70c 100644 --- a/Tests/groups/group transform 1.ts +++ b/Tests/groups/group transform 1.ts @@ -1,6 +1,6 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var robot: Phaser.Group; var eye: Phaser.Sprite, @@ -10,14 +10,14 @@ leftLeg: Phaser.Sprite, rightLeg: Phaser.Sprite; - function init() { + function preload() { game.load.image('eye', 'assets/sprites/robot/eye.png'); game.load.image('body', 'assets/sprites/robot/body.png'); game.load.image('arm-l', 'assets/sprites/robot/arm-l.png'); game.load.image('arm-r', 'assets/sprites/robot/arm-r.png'); game.load.image('leg-l', 'assets/sprites/robot/leg-l.png'); game.load.image('leg-r', 'assets/sprites/robot/leg-r.png'); - game.load.start(); + } function create() { // Add some items. diff --git a/Tests/groups/group transform 2.ts b/Tests/groups/group transform 2.ts index fbb72eba..e37ab4f3 100644 --- a/Tests/groups/group transform 2.ts +++ b/Tests/groups/group transform 2.ts @@ -1,6 +1,6 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var robot: Phaser.Group; var eye: Phaser.Sprite, @@ -10,7 +10,7 @@ leftLeg: Phaser.Sprite, rightLeg: Phaser.Sprite; - function init() { + function preload() { game.load.image('eye', 'assets/sprites/robot/eye.png'); game.load.image('body', 'assets/sprites/robot/body.png'); game.load.image('arm-l', 'assets/sprites/robot/arm-l.png'); @@ -18,7 +18,7 @@ game.load.image('leg-l', 'assets/sprites/robot/leg-l.png'); game.load.image('leg-r', 'assets/sprites/robot/leg-r.png'); - game.load.start(); + } function create() { // Add some items. diff --git a/Tests/groups/group transform 3.ts b/Tests/groups/group transform 3.ts index 8d46d2f2..d1a04298 100644 --- a/Tests/groups/group transform 3.ts +++ b/Tests/groups/group transform 3.ts @@ -1,6 +1,6 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var robot: Phaser.Group; var eye: Phaser.Sprite, @@ -10,7 +10,7 @@ leftLeg: Phaser.Sprite, rightLeg: Phaser.Sprite; - function init() { + function preload() { game.load.image('eye', 'assets/sprites/robot/eye.png'); game.load.image('body', 'assets/sprites/robot/body.png'); game.load.image('arm-l', 'assets/sprites/robot/arm-l.png'); @@ -18,7 +18,7 @@ game.load.image('leg-l', 'assets/sprites/robot/leg-l.png'); game.load.image('leg-r', 'assets/sprites/robot/leg-r.png'); - game.load.start(); + } function create() { // Add some items. diff --git a/Tests/groups/recycle 1.ts b/Tests/groups/recycle 1.ts index 12ad194e..a75a2280 100644 --- a/Tests/groups/recycle 1.ts +++ b/Tests/groups/recycle 1.ts @@ -1,15 +1,15 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var friendAndFoe: Phaser.Group, enemies: Phaser.Group; - function init() { + function preload() { game.load.image('ufo', 'assets/sprites/ufo.png'); game.load.image('baddie', 'assets/sprites/space-baddie.png'); game.load.spritesheet('button', 'assets/buttons/baddie-buttons.png', 224, 70); - game.load.start(); + } function create() { // Create some local groups for later use. diff --git a/Tests/groups/recycle 2.ts b/Tests/groups/recycle 2.ts index 1e5df09d..1dd33315 100644 --- a/Tests/groups/recycle 2.ts +++ b/Tests/groups/recycle 2.ts @@ -1,15 +1,15 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var friendAndFoe: Phaser.Group, enemies: Phaser.Group; - function init() { + function preload() { game.load.image('ufo', 'assets/sprites/ufo.png'); game.load.image('baddie', 'assets/sprites/space-baddie.png'); game.load.spritesheet('button', 'assets/buttons/baddie-buttons.png', 224, 70); - game.load.start(); + } function create() { // Create some local groups for later use. diff --git a/Tests/groups/remove.ts b/Tests/groups/remove.ts index cb9907f6..24cddc55 100644 --- a/Tests/groups/remove.ts +++ b/Tests/groups/remove.ts @@ -1,15 +1,15 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); // Group contains items. var items: Phaser.Group; - function init() { + function preload() { game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90); game.load.image('rect', 'assets/tests/200x100corners.png'); game.load.image('rect2', 'assets/tests/200x100corners2.png'); - game.load.start(); + } function create() { // Create item container group. diff --git a/Tests/groups/replace.ts b/Tests/groups/replace.ts index 04d8a1cb..6e9f9eb9 100644 --- a/Tests/groups/replace.ts +++ b/Tests/groups/replace.ts @@ -1,15 +1,15 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); // Left and right group. var left: Phaser.Group, right: Phaser.Group; // The first selected item. var selected: Phaser.Sprite = null; - function init() { + function preload() { game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90); - game.load.start(); + } function create() { left = game.add.group(); diff --git a/Tests/groups/set all.ts b/Tests/groups/set all.ts index d1193a89..ffa20eb7 100644 --- a/Tests/groups/set all.ts +++ b/Tests/groups/set all.ts @@ -1,12 +1,12 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var baseIncSpeed: Number = 0.006; - function init() { + function preload() { game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90); - game.load.start(); + } function create() { // Add some items. diff --git a/Tests/groups/sort 1.ts b/Tests/groups/sort 1.ts index 61bed6ab..e521c8cc 100644 --- a/Tests/groups/sort 1.ts +++ b/Tests/groups/sort 1.ts @@ -1,13 +1,13 @@ (function() { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var xTop: Phaser.Group, yTop: Phaser.Group, zTop: Phaser.Group; - function init() { + function preload() { game.load.image('cell', 'assets/sprites/diamond.png'); - game.load.start(); + } function create() { // Create 3 groups which will have different sort "index". diff --git a/Tests/groups/sort 2.ts b/Tests/groups/sort 2.ts index ad82ab90..51c8a5b1 100644 --- a/Tests/groups/sort 2.ts +++ b/Tests/groups/sort 2.ts @@ -1,13 +1,13 @@ (function() { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); // Wabbits inside this group is sorted by its "dead" property. // Dead wabbits behinds the others. var wabbits: Phaser.Group; - function init() { + function preload() { game.load.image('wabbit', 'assets/sprites/wabbit.png'); - game.load.start(); + } function create() { // Create container group. diff --git a/Tests/groups/sub groups.ts b/Tests/groups/sub groups.ts index 58f20493..96bbee13 100644 --- a/Tests/groups/sub groups.ts +++ b/Tests/groups/sub groups.ts @@ -1,6 +1,6 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); // Groups for storing friends and enemies, may use for collision later. var friendAndFoe: Phaser.Group, @@ -10,11 +10,11 @@ var normalBaddies: Phaser.Group, purpleBaddies: Phaser.Group; - function init() { + function preload() { game.load.image('ufo', 'assets/sprites/ufo.png'); game.load.image('baddie', 'assets/sprites/space-baddie.png'); game.load.image('purple-baddie', 'assets/sprites/space-baddie-purple.png'); - game.load.start(); + } function create() { // Create some local groups for later use. diff --git a/Tests/groups/swap children.js b/Tests/groups/swap children.js index ea94dadb..51cef254 100644 --- a/Tests/groups/swap children.js +++ b/Tests/groups/swap children.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('atari2', 'assets/sprites/atari800xl.png'); - game.load.start(); } var atari1; var atari2; diff --git a/Tests/groups/swap children.ts b/Tests/groups/swap children.ts index c824f049..51f12245 100644 --- a/Tests/groups/swap children.ts +++ b/Tests/groups/swap children.ts @@ -2,14 +2,14 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('atari2', 'assets/sprites/atari800xl.png'); - game.load.start(); + } diff --git a/Tests/input/bring to top.js b/Tests/input/bring to top.js index b1ae4393..ff97e587 100644 --- a/Tests/input/bring to top.js +++ b/Tests/input/bring to top.js @@ -1,7 +1,7 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('atari2', 'assets/sprites/atari800xl.png'); game.load.image('atari4', 'assets/sprites/atari800.png'); @@ -10,7 +10,6 @@ game.load.image('firstaid', 'assets/sprites/firstaid.png'); game.load.image('diamond', 'assets/sprites/diamond.png'); game.load.image('mushroom', 'assets/sprites/mushroom2.png'); - game.load.start(); } function create() { // This returns an array of all the image keys in the cache diff --git a/Tests/input/bring to top.ts b/Tests/input/bring to top.ts index 8157ea94..9b05718c 100644 --- a/Tests/input/bring to top.ts +++ b/Tests/input/bring to top.ts @@ -2,9 +2,9 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('atari2', 'assets/sprites/atari800xl.png'); @@ -14,7 +14,7 @@ game.load.image('firstaid', 'assets/sprites/firstaid.png'); game.load.image('diamond', 'assets/sprites/diamond.png'); game.load.image('mushroom', 'assets/sprites/mushroom2.png'); - game.load.start(); + } diff --git a/Tests/input/drag sprite 1.js b/Tests/input/drag sprite 1.js index ed426113..ccd54b7a 100644 --- a/Tests/input/drag sprite 1.js +++ b/Tests/input/drag sprite 1.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/atari130xe.png'); - game.load.start(); } var sprite; function create() { diff --git a/Tests/input/drag sprite 1.ts b/Tests/input/drag sprite 1.ts index 2c0b2f07..daebf83d 100644 --- a/Tests/input/drag sprite 1.ts +++ b/Tests/input/drag sprite 1.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/atari130xe.png'); - game.load.start(); + } diff --git a/Tests/input/drag sprite 2.js b/Tests/input/drag sprite 2.js index fca1ea5a..20eef4c9 100644 --- a/Tests/input/drag sprite 2.js +++ b/Tests/input/drag sprite 2.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/atari800.png'); - game.load.start(); } var sprite; function create() { diff --git a/Tests/input/drag sprite 2.ts b/Tests/input/drag sprite 2.ts index fe38a089..fc5fcf2f 100644 --- a/Tests/input/drag sprite 2.ts +++ b/Tests/input/drag sprite 2.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/atari800.png'); - game.load.start(); + } diff --git a/Tests/input/drag sprite 3.js b/Tests/input/drag sprite 3.js index 92287e76..8fd10483 100644 --- a/Tests/input/drag sprite 3.js +++ b/Tests/input/drag sprite 3.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/atari800.png'); - game.load.start(); } var sprite; function create() { diff --git a/Tests/input/drag sprite 3.ts b/Tests/input/drag sprite 3.ts index c8f2c27c..afd6f6e8 100644 --- a/Tests/input/drag sprite 3.ts +++ b/Tests/input/drag sprite 3.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/atari800.png'); - game.load.start(); + } diff --git a/Tests/input/drop limitation.ts b/Tests/input/drop limitation.ts index 4f6e47be..608000da 100644 --- a/Tests/input/drop limitation.ts +++ b/Tests/input/drop limitation.ts @@ -1,10 +1,10 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.load.spritesheet('item', 'assets/buttons/number-buttons-90x90.png', 90, 90); - game.load.start(); + } function create() { // Add some items to left side, and set a onDragStop listener diff --git a/Tests/input/game scale 1.js b/Tests/input/game scale 1.js index 46a460a3..f0b705fc 100644 --- a/Tests/input/game scale 1.js +++ b/Tests/input/game scale 1.js @@ -1,15 +1,14 @@ /// (function () { // Here we create a tiny game (320x240 in size) - var game = new Phaser.Game(this, 'game', 320, 240, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 320, 240, preload, create, update, render); + function preload() { // This sets a limit on the up-scale game.stage.scale.maxWidth = 800; game.stage.scale.maxHeight = 600; // Then we tell Phaser that we want it to scale up to whatever the browser can handle, but to do it proportionally game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL; game.load.image('melon', 'assets/sprites/melon.png'); - game.load.start(); } function create() { game.world.setSize(2000, 2000); diff --git a/Tests/input/game scale 1.ts b/Tests/input/game scale 1.ts index 47ffd3fc..57ecc714 100644 --- a/Tests/input/game scale 1.ts +++ b/Tests/input/game scale 1.ts @@ -3,9 +3,9 @@ (function () { // Here we create a tiny game (320x240 in size) - var game = new Phaser.Game(this, 'game', 320, 240, init, create, update, render); + var game = new Phaser.Game(this, 'game', 320, 240, preload, create, update, render); - function init() { + function preload() { // This sets a limit on the up-scale game.stage.scale.maxWidth = 800; @@ -16,7 +16,7 @@ game.load.image('melon', 'assets/sprites/melon.png'); - game.load.start(); + } diff --git a/Tests/input/keyboard 1.ts b/Tests/input/keyboard 1.ts index c67a930a..00b83df8 100644 --- a/Tests/input/keyboard 1.ts +++ b/Tests/input/keyboard 1.ts @@ -1,13 +1,13 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); var ufo: Phaser.Sprite, leftBtn: Phaser.Sprite, rightBtn: Phaser.Sprite; var speed: Number = 4; - function init() { + function preload() { game.world.setSize(1280, 600, true); game.load.image('ground', 'assets/tests/ground-2x.png'); game.load.image('river', 'assets/tests/river-2x.png'); @@ -20,7 +20,7 @@ game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21); - game.load.start(); + } function create() { // background images diff --git a/Tests/input/keyboard 2.ts b/Tests/input/keyboard 2.ts index 130fe9f8..9c713b47 100644 --- a/Tests/input/keyboard 2.ts +++ b/Tests/input/keyboard 2.ts @@ -1,6 +1,6 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); var ufo: Phaser.Sprite, leftBtn: Phaser.Sprite, @@ -9,7 +9,7 @@ var speed: Number = 4; - function init() { + function preload() { game.world.setSize(1280, 600, true); game.load.image('ground', 'assets/tests/ground-2x.png'); game.load.image('river', 'assets/tests/river-2x.png'); @@ -23,7 +23,7 @@ game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21); - game.load.start(); + } function create() { // background images diff --git a/Tests/input/motion lock 2.js b/Tests/input/motion lock 2.js index 2cd1e516..7763e6e4 100644 --- a/Tests/input/motion lock 2.js +++ b/Tests/input/motion lock 2.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/darkwing_crazy.png'); - game.load.start(); } var sprite; function create() { diff --git a/Tests/input/motion lock 2.ts b/Tests/input/motion lock 2.ts index a573dbe1..900d8782 100644 --- a/Tests/input/motion lock 2.ts +++ b/Tests/input/motion lock 2.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/darkwing_crazy.png'); - game.load.start(); + } diff --git a/Tests/input/motion lock.js b/Tests/input/motion lock.js index 7d3d71c9..b1084922 100644 --- a/Tests/input/motion lock.js +++ b/Tests/input/motion lock.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/parsec.png'); - game.load.start(); } var sprite; function create() { diff --git a/Tests/input/motion lock.ts b/Tests/input/motion lock.ts index 833f51b6..e9b4625f 100644 --- a/Tests/input/motion lock.ts +++ b/Tests/input/motion lock.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/parsec.png'); - game.load.start(); + } diff --git a/Tests/input/over sprite 1.js b/Tests/input/over sprite 1.js index f2330cb2..60856943 100644 --- a/Tests/input/over sprite 1.js +++ b/Tests/input/over sprite 1.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/atari130xe.png'); - game.load.start(); } var sprite; function create() { diff --git a/Tests/input/over sprite 1.ts b/Tests/input/over sprite 1.ts index 5b7e7c2d..63bdbcdf 100644 --- a/Tests/input/over sprite 1.ts +++ b/Tests/input/over sprite 1.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/atari130xe.png'); - game.load.start(); + } diff --git a/Tests/input/over sprite 2.js b/Tests/input/over sprite 2.js index 95f94bb9..2172f135 100644 --- a/Tests/input/over sprite 2.js +++ b/Tests/input/over sprite 2.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/shinyball.png'); - game.load.start(); } var sprite; function create() { diff --git a/Tests/input/over sprite 2.ts b/Tests/input/over sprite 2.ts index 0939cbd9..2fa65a03 100644 --- a/Tests/input/over sprite 2.ts +++ b/Tests/input/over sprite 2.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('sprite', 'assets/sprites/shinyball.png'); - game.load.start(); + } diff --git a/Tests/input/point in rotated sprite.js b/Tests/input/point in rotated sprite.js index b187ef3b..65f14e11 100644 --- a/Tests/input/point in rotated sprite.js +++ b/Tests/input/point in rotated sprite.js @@ -1,9 +1,8 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.load.image('sprite', 'assets/sprites/atari130xe.png'); - game.load.start(); } var sprite; var rotate = false; diff --git a/Tests/input/point in rotated sprite.ts b/Tests/input/point in rotated sprite.ts index bdba6743..7a28d25d 100644 --- a/Tests/input/point in rotated sprite.ts +++ b/Tests/input/point in rotated sprite.ts @@ -2,12 +2,12 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.load.image('sprite', 'assets/sprites/atari130xe.png'); - game.load.start(); + } diff --git a/Tests/input/rotated sprites.js b/Tests/input/rotated sprites.js index 9dd56737..dd5e2ea2 100644 --- a/Tests/input/rotated sprites.js +++ b/Tests/input/rotated sprites.js @@ -1,12 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('atari2', 'assets/sprites/atari800xl.png'); game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png'); - game.load.start(); } var atari1; var atari2; diff --git a/Tests/input/rotated sprites.ts b/Tests/input/rotated sprites.ts index c31a5da0..04faec21 100644 --- a/Tests/input/rotated sprites.ts +++ b/Tests/input/rotated sprites.ts @@ -2,15 +2,15 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('atari2', 'assets/sprites/atari800xl.png'); game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png'); - game.load.start(); + } diff --git a/Tests/input/snap 1.js b/Tests/input/snap 1.js index 8d47761b..ccd7128d 100644 --- a/Tests/input/snap 1.js +++ b/Tests/input/snap 1.js @@ -1,12 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png'); game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('atari2', 'assets/sprites/atari800xl.png'); - game.load.start(); } var atari1; var atari2; diff --git a/Tests/input/snap 1.ts b/Tests/input/snap 1.ts index 268c1856..3f6481aa 100644 --- a/Tests/input/snap 1.ts +++ b/Tests/input/snap 1.ts @@ -2,15 +2,15 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png'); game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('atari2', 'assets/sprites/atari800xl.png'); - game.load.start(); + } diff --git a/Tests/input/touch priority.js b/Tests/input/touch priority.js index 59cf1103..03a48dea 100644 --- a/Tests/input/touch priority.js +++ b/Tests/input/touch priority.js @@ -1,12 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('atari2', 'assets/sprites/atari800xl.png'); game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png'); - game.load.start(); } var atari1; var atari2; diff --git a/Tests/input/touch priority.ts b/Tests/input/touch priority.ts index 3747c15d..beff791c 100644 --- a/Tests/input/touch priority.ts +++ b/Tests/input/touch priority.ts @@ -2,15 +2,15 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('atari1', 'assets/sprites/atari130xe.png'); game.load.image('atari2', 'assets/sprites/atari800xl.png'); game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png'); - game.load.start(); + } diff --git a/Tests/input/world coordinates.js b/Tests/input/world coordinates.js index f8a4daa0..9b1d4d84 100644 --- a/Tests/input/world coordinates.js +++ b/Tests/input/world coordinates.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.world.setSize(1920, 1200, true); game.load.image('backdrop', 'assets/pics/remember-me.jpg'); - game.load.start(); } var test; function create() { diff --git a/Tests/input/world coordinates.ts b/Tests/input/world coordinates.ts index 26466333..760d1a2c 100644 --- a/Tests/input/world coordinates.ts +++ b/Tests/input/world coordinates.ts @@ -2,15 +2,15 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.world.setSize(1920, 1200, true); game.load.image('backdrop', 'assets/pics/remember-me.jpg'); - game.load.start(); + } diff --git a/Tests/input/world drag.js b/Tests/input/world drag.js index cbc10fce..a3efebd6 100644 --- a/Tests/input/world drag.js +++ b/Tests/input/world drag.js @@ -1,11 +1,10 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.world.setSize(1920, 1200, true); game.load.image('backdrop', 'assets/pics/remember-me.jpg'); game.load.image('diamond', 'assets/sprites/diamond.png'); - game.load.start(); } var test; function create() { diff --git a/Tests/input/world drag.ts b/Tests/input/world drag.ts index 93444859..86f1daf8 100644 --- a/Tests/input/world drag.ts +++ b/Tests/input/world drag.ts @@ -2,16 +2,16 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.world.setSize(1920, 1200, true); game.load.image('backdrop', 'assets/pics/remember-me.jpg'); game.load.image('diamond', 'assets/sprites/diamond.png'); - game.load.start(); + } diff --git a/Tests/misc/color utils 1.ts b/Tests/misc/color utils 1.ts index 75146d8f..6bd7972b 100644 --- a/Tests/misc/color utils 1.ts +++ b/Tests/misc/color utils 1.ts @@ -1,5 +1,5 @@ (function() { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var colorWheel: Phaser.Sprite, selected: Phaser.Sprite, @@ -11,9 +11,9 @@ var rect: Phaser.Rectangle, rectSize: Number = 24; - function init() { + function preload() { game.load.image('color-wheel', 'assets/pics/color-wheel.png'); - game.load.start(); + } function create() { // Create color wheel texture. diff --git a/Tests/misc/color utils 2.ts b/Tests/misc/color utils 2.ts index 318208b1..a0d5e40a 100644 --- a/Tests/misc/color utils 2.ts +++ b/Tests/misc/color utils 2.ts @@ -1,5 +1,5 @@ (function() { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var colorWheel: Phaser.Sprite, selected: Phaser.Sprite, @@ -12,9 +12,9 @@ var rect: Phaser.Rectangle, rectSize = 24; - function init() { + function preload() { game.load.image('color-wheel', 'assets/pics/color-wheel.png'); - game.load.start(); + } function create() { // Create color wheel texture. diff --git a/Tests/misc/color utils 3.ts b/Tests/misc/color utils 3.ts index 316ddcc5..08336bc2 100644 --- a/Tests/misc/color utils 3.ts +++ b/Tests/misc/color utils 3.ts @@ -1,5 +1,5 @@ (function() { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); var colorWheel: Phaser.Sprite, selected: Phaser.Sprite, @@ -20,9 +20,9 @@ var rect: Phaser.Rectangle, rectSize: Number = 24; - function init() { + function preload() { game.load.image('color-wheel', 'assets/pics/color-wheel.png'); - game.load.start(); + } function create() { // Create color wheel texture. diff --git a/Tests/misc/dynamic texture 3.ts b/Tests/misc/dynamic texture 3.ts index f7437e16..cb75104c 100644 --- a/Tests/misc/dynamic texture 3.ts +++ b/Tests/misc/dynamic texture 3.ts @@ -1,12 +1,12 @@ (function() { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render); // Pattern texture for tiling render to the stage later. var pattern: Phaser.DynamicTexture; - function init() { + function preload() { game.load.spritesheet('cat', 'assets/sprites/baddie_cat_1.png', 16, 16); - game.load.start(); + } function create() { // Create a simple pattern first. diff --git a/Tests/misc/point1.js b/Tests/misc/point1.js index 6b2b2b83..bae9f933 100644 --- a/Tests/misc/point1.js +++ b/Tests/misc/point1.js @@ -1,11 +1,10 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.load.image('box2', 'assets/tests/320x200.png'); game.load.image('box1', 'assets/sprites/oz_pov_melting_disk.png'); game.load.image('box', 'assets/sprites/bunny.png'); - game.load.start(); } var sprite; var rotate = false; diff --git a/Tests/misc/point1.ts b/Tests/misc/point1.ts index 1dcfb0b0..a4b05730 100644 --- a/Tests/misc/point1.ts +++ b/Tests/misc/point1.ts @@ -2,14 +2,14 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.load.image('box2', 'assets/tests/320x200.png'); game.load.image('box1', 'assets/sprites/oz_pov_melting_disk.png'); game.load.image('box', 'assets/sprites/bunny.png'); - game.load.start(); + } diff --git a/Tests/misc/point2.js b/Tests/misc/point2.js index 72448870..ee550644 100644 --- a/Tests/misc/point2.js +++ b/Tests/misc/point2.js @@ -1,9 +1,8 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18); - game.load.start(); } var sprite; var rotate = false; diff --git a/Tests/misc/point2.ts b/Tests/misc/point2.ts index 499f63d6..8f0d99e3 100644 --- a/Tests/misc/point2.ts +++ b/Tests/misc/point2.ts @@ -2,12 +2,12 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18); - game.load.start(); + } diff --git a/Tests/misc/point3.js b/Tests/misc/point3.js index 923e4ce0..b4ea9625 100644 --- a/Tests/misc/point3.js +++ b/Tests/misc/point3.js @@ -1,9 +1,8 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData); - game.load.start(); } var sprite; var rotate = false; diff --git a/Tests/misc/point3.ts b/Tests/misc/point3.ts index 3fd9752f..8554d50e 100644 --- a/Tests/misc/point3.ts +++ b/Tests/misc/point3.ts @@ -2,12 +2,12 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData); - game.load.start(); + } diff --git a/Tests/mobile/sprite test 1.js b/Tests/mobile/sprite test 1.js index 633db779..c202e4ae 100644 --- a/Tests/mobile/sprite test 1.js +++ b/Tests/mobile/sprite test 1.js @@ -1,12 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 320, 400, init, create); + var game = new Phaser.Game(this, 'game', 320, 400, preload, create); var emitter; - function init() { + function preload() { game.load.image('backdrop1', 'assets/pics/atari_fujilogo.png'); game.load.image('backdrop2', 'assets/pics/acryl_bladerunner.png'); game.load.image('jet', 'assets/sprites/carrot.png'); - game.load.start(); // This can help a lot on crappy old Android phones :) //game.framerate = 30; game.stage.backgroundColor = 'rgb(0,0,0)'; diff --git a/Tests/mobile/sprite test 1.ts b/Tests/mobile/sprite test 1.ts index 8c852ef7..1c22905d 100644 --- a/Tests/mobile/sprite test 1.ts +++ b/Tests/mobile/sprite test 1.ts @@ -2,17 +2,17 @@ (function () { - var game = new Phaser.Game(this, 'game', 320, 400, init, create); + var game = new Phaser.Game(this, 'game', 320, 400, preload, create); var emitter: Phaser.ArcadeEmitter; - function init() { + function preload() { game.load.image('backdrop1', 'assets/pics/atari_fujilogo.png'); game.load.image('backdrop2', 'assets/pics/acryl_bladerunner.png'); game.load.image('jet', 'assets/sprites/carrot.png'); - game.load.start(); + // This can help a lot on crappy old Android phones :) //game.framerate = 30; diff --git a/Tests/particles/graphic emitter.js b/Tests/particles/graphic emitter.js index 1b7e59f9..bcd4d846 100644 --- a/Tests/particles/graphic emitter.js +++ b/Tests/particles/graphic emitter.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); var emitter; - function init() { + function preload() { game.load.image('jet', 'assets/sprites/jets.png'); - game.load.start(); } function create() { emitter = game.add.emitter(game.stage.centerX, game.stage.centerY); diff --git a/Tests/particles/graphic emitter.ts b/Tests/particles/graphic emitter.ts index 8d17e879..2472ca64 100644 --- a/Tests/particles/graphic emitter.ts +++ b/Tests/particles/graphic emitter.ts @@ -2,15 +2,15 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); var emitter: Phaser.ArcadeEmitter; - function init() { + function preload() { game.load.image('jet', 'assets/sprites/jets.png'); - game.load.start(); + } diff --git a/Tests/particles/mousetrail.js b/Tests/particles/mousetrail.js index eb456d73..67b831e8 100644 --- a/Tests/particles/mousetrail.js +++ b/Tests/particles/mousetrail.js @@ -1,11 +1,10 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); var emitter; - function init() { + function preload() { game.load.image('jet', 'assets/sprites/particle1.png'); game.load.image('starfield', 'assets/misc/starfield.jpg'); - game.load.start(); } var scroller; var emitter; diff --git a/Tests/particles/mousetrail.ts b/Tests/particles/mousetrail.ts index 7da3a211..17da8c99 100644 --- a/Tests/particles/mousetrail.ts +++ b/Tests/particles/mousetrail.ts @@ -2,15 +2,15 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); var emitter: Phaser.ArcadeEmitter; - function init() { + function preload() { game.load.image('jet', 'assets/sprites/particle1.png'); game.load.image('starfield', 'assets/misc/starfield.jpg'); - game.load.start(); + } diff --git a/Tests/particles/multiple streams.js b/Tests/particles/multiple streams.js index 1ec28b3d..056c88f6 100644 --- a/Tests/particles/multiple streams.js +++ b/Tests/particles/multiple streams.js @@ -1,20 +1,19 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); var emitter1; var emitter2; var emitter3; var emitter4; var emitter5; var emitter6; - function init() { + function preload() { game.load.image('ball1', 'assets/sprites/aqua_ball.png'); game.load.image('ball2', 'assets/sprites/yellow_ball.png'); game.load.image('ball3', 'assets/sprites/red_ball.png'); game.load.image('ball4', 'assets/sprites/purple_ball.png'); game.load.image('ball5', 'assets/sprites/blue_ball.png'); game.load.image('ball6', 'assets/sprites/green_ball.png'); - game.load.start(); } function makeEmitter(emitter, x, y, graphic) { emitter = game.add.emitter(x, y); diff --git a/Tests/particles/multiple streams.ts b/Tests/particles/multiple streams.ts index dee1d2e7..01ff39ff 100644 --- a/Tests/particles/multiple streams.ts +++ b/Tests/particles/multiple streams.ts @@ -2,7 +2,7 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); var emitter1: Phaser.ArcadeEmitter; var emitter2: Phaser.ArcadeEmitter; @@ -11,7 +11,7 @@ var emitter5: Phaser.ArcadeEmitter; var emitter6: Phaser.ArcadeEmitter; - function init() { + function preload() { game.load.image('ball1', 'assets/sprites/aqua_ball.png'); game.load.image('ball2', 'assets/sprites/yellow_ball.png'); @@ -20,7 +20,7 @@ game.load.image('ball5', 'assets/sprites/blue_ball.png'); game.load.image('ball6', 'assets/sprites/green_ball.png'); - game.load.start(); + } diff --git a/Tests/particles/sprite emitter.js b/Tests/particles/sprite emitter.js index 33418955..524969f6 100644 --- a/Tests/particles/sprite emitter.js +++ b/Tests/particles/sprite emitter.js @@ -24,15 +24,14 @@ var customParticle = (function (_super) { return customParticle; })(Phaser.ArcadeParticle); (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); var emitter; - function init() { + function preload() { game.load.image('carrot', 'assets/sprites/carrot.png'); game.load.image('melon', 'assets/sprites/melon.png'); game.load.image('eggplant', 'assets/sprites/eggplant.png'); game.load.image('mushroom', 'assets/sprites/mushroom.png'); game.load.image('pineapple', 'assets/sprites/pineapple.png'); - game.load.start(); } function create() { emitter = game.add.emitter(game.stage.centerX, 50); diff --git a/Tests/particles/sprite emitter.ts b/Tests/particles/sprite emitter.ts index 2643ccdc..89719dfb 100644 --- a/Tests/particles/sprite emitter.ts +++ b/Tests/particles/sprite emitter.ts @@ -19,11 +19,11 @@ class customParticle extends Phaser.ArcadeParticle { (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); var emitter: Phaser.ArcadeEmitter; - function init() { + function preload() { game.load.image('carrot', 'assets/sprites/carrot.png'); game.load.image('melon', 'assets/sprites/melon.png'); @@ -31,7 +31,7 @@ class customParticle extends Phaser.ArcadeParticle { game.load.image('mushroom', 'assets/sprites/mushroom.png'); game.load.image('pineapple', 'assets/sprites/pineapple.png'); - game.load.start(); + } diff --git a/Tests/particles/when particles collide.js b/Tests/particles/when particles collide.js index 09b713e5..08c97b99 100644 --- a/Tests/particles/when particles collide.js +++ b/Tests/particles/when particles collide.js @@ -1,12 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); var leftEmitter; var rightEmitter; - function init() { + function preload() { game.load.image('ball1', 'assets/sprites/aqua_ball.png'); game.load.image('ball2', 'assets/sprites/yellow_ball.png'); - game.load.start(); } function create() { leftEmitter = game.add.emitter(0, game.stage.centerY - 200); diff --git a/Tests/particles/when particles collide.ts b/Tests/particles/when particles collide.ts index 53278128..ec41e9d1 100644 --- a/Tests/particles/when particles collide.ts +++ b/Tests/particles/when particles collide.ts @@ -2,17 +2,17 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); var leftEmitter: Phaser.ArcadeEmitter; var rightEmitter: Phaser.ArcadeEmitter; - function init() { + function preload() { game.load.image('ball1', 'assets/sprites/aqua_ball.png'); game.load.image('ball2', 'assets/sprites/yellow_ball.png'); - game.load.start(); + } diff --git a/Tests/phaser.js b/Tests/phaser.js index c779dea5..05f74d9e 100644 --- a/Tests/phaser.js +++ b/Tests/phaser.js @@ -5204,7 +5204,7 @@ var Phaser; if (camera == null) { - camera = this._game.camera; + camera = this.game.camera; } var objectScreenPos: Point = objectOrGroup.getScreenXY(null, camera); @@ -5286,7 +5286,7 @@ var Phaser; point = new Phaser.Point(); } if(camera == null) { - camera = this._game.camera; + camera = this.game.camera; } point.x = sprite.x - camera.x * sprite.transform.scrollFactor.x; point.y = sprite.y - camera.y * sprite.transform.scrollFactor.y; @@ -5302,7 +5302,7 @@ var Phaser; /* static setBoundsFromWorld(action?: number = GameObject.OUT_OF_BOUNDS_STOP) { - this.setBounds(this._game.world.bounds.x, this._game.world.bounds.y, this._game.world.bounds.width, this._game.world.bounds.height); + this.setBounds(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height); this.outOfBoundsAction = action; } @@ -7396,21 +7396,24 @@ var Phaser; * Loader constructor * * @param game {Phaser.Game} Current game instance. - * @param callback {function} This will be called when assets completely loaded. */ - function Loader(game, callback) { + function Loader(game) { /** * The crossOrigin value applied to loaded images * @type {string} */ this.crossOrigin = ''; - this._game = game; - this._gameCreateComplete = callback; + this.game = game; this._keys = []; this._fileList = { }; this._xhr = new XMLHttpRequest(); this._queueSize = 0; + this.isLoading = false; + this.onFileComplete = new Phaser.Signal(); + this.onFileError = new Phaser.Signal(); + this.onLoadStart = new Phaser.Signal(); + this.onLoadComplete = new Phaser.Signal(); } Loader.TEXTURE_ATLAS_JSON_ARRAY = 0; Loader.TEXTURE_ATLAS_JSON_HASH = 1; @@ -7420,6 +7423,7 @@ var Phaser; */ function () { this._queueSize = 0; + this.isLoading = false; }; Object.defineProperty(Loader.prototype, "queueSize", { get: function () { @@ -7617,29 +7621,22 @@ var Phaser; }; Loader.prototype.start = /** * Load assets. - * @param onFileLoadCallback {function} Called when each file loaded successfully. - * @param onCompleteCallback {function} Called when all assets completely loaded. */ - function (onFileLoadCallback, onCompleteCallback) { - if (typeof onFileLoadCallback === "undefined") { onFileLoadCallback = null; } - if (typeof onCompleteCallback === "undefined") { onCompleteCallback = null; } + function () { + if(this.isLoading) { + return; + } this.progress = 0; this.hasLoaded = false; - this._onComplete = onCompleteCallback; - if(onCompleteCallback == null) { - this._onComplete = this._game.onCreateCallback; - } - this._onFileLoad = onFileLoadCallback; + this.isLoading = true; + this.onLoadStart.dispatch(this.queueSize); if(this._keys.length > 0) { this._progressChunk = 100 / this._keys.length; this.loadFile(); } else { this.progress = 100; this.hasLoaded = true; - this._gameCreateComplete.call(this._game); - if(this._onComplete !== null) { - this._onComplete.call(this._game.callbackContext); - } + this.onLoadComplete.dispatch(); } }; Loader.prototype.loadFile = /** @@ -7668,7 +7665,7 @@ var Phaser; file.url = this.getAudioURL(file.url); if(file.url !== null) { // WebAudio or Audio Tag? - if(this._game.sound.usingWebAudio) { + if(this.game.sound.usingWebAudio) { this._xhr.open("GET", file.url, true); this._xhr.responseType = "arraybuffer"; this._xhr.onload = function () { @@ -7678,8 +7675,8 @@ var Phaser; return _this.fileError(file.key); }; this._xhr.send(); - } else if(this._game.sound.usingAudioTag) { - if(this._game.sound.touchLocked) { + } else if(this.game.sound.usingAudioTag) { + if(this.game.sound.touchLocked) { // If audio is locked we can't do this yet, so need to queue this load request somehow. Bum. file.data = new Audio(); file.data.name = file.key; @@ -7694,7 +7691,7 @@ var Phaser; }; file.data.preload = 'auto'; file.data.src = file.url; - file.data.addEventListener('canplaythrough', Phaser.GAMES[this._game.id].load.fileComplete(file.key), false); + file.data.addEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete(file.key), false); file.data.load(); } } @@ -7718,9 +7715,7 @@ var Phaser; for(var i = 0; i < urls.length; i++) { extension = urls[i].toLowerCase(); extension = extension.substr((Math.max(0, extension.lastIndexOf(".")) || Infinity) + 1); - if(this._game.device.canPlayAudio(extension)) { - //console.log('getAudioURL', urls[i]); - //console.log(urls[i]); + if(this.game.device.canPlayAudio(extension)) { return urls[i]; } } @@ -7733,6 +7728,7 @@ var Phaser; function (key) { this._fileList[key].loaded = true; this._fileList[key].error = true; + this.onFileError.dispatch(key); throw new Error("Phaser.Loader error loading file: " + key); this.nextFile(key, false); }; @@ -7751,14 +7747,14 @@ var Phaser; var loadNext = true; switch(file.type) { case 'image': - this._game.cache.addImage(file.key, file.url, file.data); + this.game.cache.addImage(file.key, file.url, file.data); break; case 'spritesheet': - this._game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax); + this.game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax); break; case 'textureatlas': if(file.atlasURL == null) { - this._game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format); + this.game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format); } else { // Load the JSON or XML before carrying on with the next file loadNext = false; @@ -7780,27 +7776,27 @@ var Phaser; } break; case 'audio': - if(this._game.sound.usingWebAudio) { + if(this.game.sound.usingWebAudio) { file.data = this._xhr.response; - this._game.cache.addSound(file.key, file.url, file.data, true, false); + this.game.cache.addSound(file.key, file.url, file.data, true, false); if(file.autoDecode) { - this._game.cache.updateSound(key, 'isDecoding', true); + this.game.cache.updateSound(key, 'isDecoding', true); var that = this; var key = file.key; - this._game.sound.context.decodeAudioData(file.data, function (buffer) { + this.game.sound.context.decodeAudioData(file.data, function (buffer) { if(buffer) { - that._game.cache.decodedSound(key, buffer); + that.game.cache.decodedSound(key, buffer); } }); } } else { - file.data.removeEventListener('canplaythrough', Phaser.GAMES[this._game.id].load.fileComplete); - this._game.cache.addSound(file.key, file.url, file.data, false, true); + file.data.removeEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete); + this.game.cache.addSound(file.key, file.url, file.data, false, true); } break; case 'text': file.data = this._xhr.response; - this._game.cache.addText(file.key, file.url, file.data); + this.game.cache.addText(file.key, file.url, file.data); break; } if(loadNext) { @@ -7814,7 +7810,7 @@ var Phaser; function (key) { var data = JSON.parse(this._xhr.response); var file = this._fileList[key]; - this._game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format); + this.game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format); this.nextFile(key, true); }; Loader.prototype.dataLoadError = /** @@ -7846,7 +7842,7 @@ var Phaser; throw new Error("Phaser.Loader. Invalid XML given"); } var file = this._fileList[key]; - this._game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format); + this.game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format); this.nextFile(key, true); }; Loader.prototype.nextFile = /** @@ -7859,18 +7855,14 @@ var Phaser; if(this.progress > 100) { this.progress = 100; } - if(this._onFileLoad) { - this._onFileLoad.call(this._game.callbackContext, this.progress, previousKey, success); - } + this.onFileComplete.dispatch(this.progress, previousKey, success, this._queueSize - this._keys.length, this._queueSize); if(this._keys.length > 0) { this.loadFile(); } else { this.hasLoaded = true; + this.isLoading = false; this.removeAll(); - this._gameCreateComplete.call(this._game); - if(this._onComplete !== null) { - this._onComplete.call(this._game.callbackContext); - } + this.onLoadComplete.dispatch(); } }; Loader.prototype.checkKeyExists = /** @@ -7995,7 +7987,7 @@ var Phaser; */ function Cache(game) { this.onSoundUnlock = new Phaser.Signal(); - this._game = game; + this.game = game; this._canvases = { }; this._images = { @@ -8034,7 +8026,7 @@ var Phaser; frameWidth: frameWidth, frameHeight: frameHeight }; - this._images[key].frameData = Phaser.AnimationLoader.parseSpriteSheet(this._game, key, frameWidth, frameHeight, frameMax); + this._images[key].frameData = Phaser.AnimationLoader.parseSpriteSheet(this.game, key, frameWidth, frameHeight, frameMax); }; Cache.prototype.addTextureAtlas = /** * Add a new texture atlas. @@ -8050,9 +8042,9 @@ var Phaser; spriteSheet: true }; if(format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY) { - this._images[key].frameData = Phaser.AnimationLoader.parseJSONData(this._game, atlasData); + this._images[key].frameData = Phaser.AnimationLoader.parseJSONData(this.game, atlasData); } else if(format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING) { - this._images[key].frameData = Phaser.AnimationLoader.parseXMLData(this._game, atlasData, format); + this._images[key].frameData = Phaser.AnimationLoader.parseXMLData(this.game, atlasData, format); } }; Cache.prototype.addImage = /** @@ -8077,7 +8069,7 @@ var Phaser; function (key, url, data, webAudio, audioTag) { if (typeof webAudio === "undefined") { webAudio = true; } if (typeof audioTag === "undefined") { audioTag = false; } - var locked = this._game.sound.touchLocked; + var locked = this.game.sound.touchLocked; var decoded = false; if(audioTag) { decoded = true; @@ -9966,7 +9958,7 @@ var Phaser; * Helper for sort. */ this._sortIndex = ''; - this._game = game; + this.game = game; this._cameras = []; this._cameraLength = 0; this.defaultCamera = this.addCamera(x, y, width, height); @@ -10006,7 +9998,7 @@ var Phaser; * @returns {Camera} The newly created camera object. */ function (x, y, width, height) { - var newCam = new Phaser.Camera(this._game, this._cameraLength, x, y, width, height); + var newCam = new Phaser.Camera(this.game, this._cameraLength, x, y, width, height); this._cameraLength = this._cameras.push(newCam); return newCam; }; @@ -10089,7 +10081,7 @@ var Phaser; */ function () { this._cameras.length = 0; - this.current = this.addCamera(0, 0, this._game.stage.width, this._game.stage.height); + this.current = this.addCamera(0, 0, this.game.stage.width, this.game.stage.height); }; return CameraManager; })(); @@ -10529,9 +10521,9 @@ var Phaser; this._chainedTweens = []; this.isRunning = false; this._object = object; - this._game = game; - this._manager = this._game.tweens; - this._interpolationFunction = this._game.math.linearInterpolation; + this.game = game; + this._manager = this.game.tweens; + this._interpolationFunction = this.game.math.linearInterpolation; this._easingFunction = Phaser.Easing.Linear.None; this._chainedTweens = []; this.onStart = new Phaser.Signal(); @@ -10587,14 +10579,14 @@ var Phaser; */ function (looped) { if (typeof looped === "undefined") { looped = false; } - if(this._game === null || this._object === null) { + if(this.game === null || this._object === null) { return; } if(looped == false) { this._manager.add(this); this.onStart.dispatch(this._object); } - this._startTime = this._game.time.now + this._delayTime; + this._startTime = this.game.time.now + this._delayTime; this.isRunning = true; for(var property in this._valuesEnd) { // This prevents the interpolation of null values or of non-existing properties @@ -10656,8 +10648,8 @@ var Phaser; }; Object.defineProperty(Tween.prototype, "parent", { set: function (value) { - this._game = value; - this._manager = this._game.tweens; + this.game = value; + this._manager = this.game.tweens; }, enumerable: true, configurable: true @@ -10707,7 +10699,7 @@ var Phaser; * @return {boolean} Return false if this completed and no need to update, otherwise return true. */ function (time) { - if(this._game.paused == true) { + if(this.game.paused == true) { if(this._pausedTime == 0) { this._pausedTime = time; } @@ -11937,7 +11929,7 @@ var Phaser; * @type {boolean} */ this.separateY = true; - this._game = game; + this.game = game; this.tilemap = tilemap; this.index = index; this.width = width; @@ -12357,8 +12349,8 @@ var Phaser; * @param game {Game} A reference to the current Game. */ function GameObjectFactory(game) { - this._game = game; - this._world = this._game.world; + this.game = game; + this._world = this.game.world; } GameObjectFactory.prototype.camera = /** * Create a new camera with specific position and size. @@ -12380,7 +12372,7 @@ var Phaser; * @returns {GeomSprite} The newly created geom sprite object. */ //public geomSprite(x: number, y: number): GeomSprite { - // return this._world.group.add(new GeomSprite(this._game, x, y)); + // return this._world.group.add(new GeomSprite(this.game, x, y)); //} /** * Create a new Button game object. @@ -12404,7 +12396,7 @@ var Phaser; if (typeof overFrame === "undefined") { overFrame = null; } if (typeof outFrame === "undefined") { outFrame = null; } if (typeof downFrame === "undefined") { downFrame = null; } - return this._world.group.add(new Phaser.UI.Button(this._game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame)); + return this._world.group.add(new Phaser.UI.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame)); }; GameObjectFactory.prototype.sprite = /** * Create a new Sprite with specific position and sprite sheet key. @@ -12418,12 +12410,12 @@ var Phaser; function (x, y, key, frame) { if (typeof key === "undefined") { key = ''; } if (typeof frame === "undefined") { frame = null; } - return this._world.group.add(new Phaser.Sprite(this._game, x, y, key, frame)); + return this._world.group.add(new Phaser.Sprite(this.game, x, y, key, frame)); }; GameObjectFactory.prototype.audio = function (key, volume, loop) { if (typeof volume === "undefined") { volume = 1; } if (typeof loop === "undefined") { loop = false; } - return this._game.sound.add(key, volume, loop); + return this.game.sound.add(key, volume, loop); }; GameObjectFactory.prototype.dynamicTexture = /** * Create a new Sprite with the physics automatically created and set to DYNAMIC. The Sprite position offset is set to its center. @@ -12437,7 +12429,7 @@ var Phaser; * @returns {Sprite} The newly created sprite object. */ //public physicsSprite(x: number, y: number, key?: string = '', frame? = null, bodyType?: number = Phaser.Types.BODY_DYNAMIC, shapeType?:number = 0): Sprite { - // return this._world.group.add(new Sprite(this._game, x, y, key, frame, bodyType, shapeType)); + // return this._world.group.add(new Sprite(this.game, x, y, key, frame, bodyType, shapeType)); //} /** * Create a new DynamicTexture with specific size. @@ -12447,7 +12439,7 @@ var Phaser; * @returns {DynamicTexture} The newly created dynamic texture object. */ function (width, height) { - return new Phaser.DynamicTexture(this._game, width, height); + return new Phaser.DynamicTexture(this.game, width, height); }; GameObjectFactory.prototype.group = /** * Create a new object container. @@ -12457,7 +12449,7 @@ var Phaser; */ function (maxSize) { if (typeof maxSize === "undefined") { maxSize = 0; } - return this._world.group.add(new Phaser.Group(this._game, maxSize)); + return this._world.group.add(new Phaser.Group(this.game, maxSize)); }; GameObjectFactory.prototype.particle = /** * Create a new Particle. @@ -12465,7 +12457,7 @@ var Phaser; * @return {Particle} The newly created particle object. */ function () { - return new Phaser.ArcadeParticle(this._game); + return new Phaser.ArcadeParticle(this.game); }; GameObjectFactory.prototype.emitter = /** * Create a new Emitter. @@ -12479,7 +12471,7 @@ var Phaser; if (typeof x === "undefined") { x = 0; } if (typeof y === "undefined") { y = 0; } if (typeof size === "undefined") { size = 0; } - return this._world.group.add(new Phaser.ArcadeEmitter(this._game, x, y, size)); + return this._world.group.add(new Phaser.ArcadeEmitter(this.game, x, y, size)); }; GameObjectFactory.prototype.scrollZone = /** * Create a new ScrollZone object with image key, position and size. @@ -12496,7 +12488,7 @@ var Phaser; if (typeof y === "undefined") { y = 0; } if (typeof width === "undefined") { width = 0; } if (typeof height === "undefined") { height = 0; } - return this._world.group.add(new Phaser.ScrollZone(this._game, key, x, y, width, height)); + return this._world.group.add(new Phaser.ScrollZone(this.game, key, x, y, width, height)); }; GameObjectFactory.prototype.tilemap = /** * Create a new Tilemap. @@ -12513,7 +12505,7 @@ var Phaser; if (typeof resizeWorld === "undefined") { resizeWorld = true; } if (typeof tileWidth === "undefined") { tileWidth = 0; } if (typeof tileHeight === "undefined") { tileHeight = 0; } - return this._world.group.add(new Phaser.Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight)); + return this._world.group.add(new Phaser.Tilemap(this.game, key, mapData, format, resizeWorld, tileWidth, tileHeight)); }; GameObjectFactory.prototype.tween = /** * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. @@ -12524,7 +12516,7 @@ var Phaser; */ function (obj, localReference) { if (typeof localReference === "undefined") { localReference = false; } - return this._game.tweens.create(obj, localReference); + return this.game.tweens.create(obj, localReference); }; GameObjectFactory.prototype.existingSprite = /** * Add an existing Sprite to the current world. @@ -12604,7 +12596,7 @@ var Phaser; * @return {Phaser.Tween} The Tween object */ function (tween) { - return this._game.tweens.add(tween); + return this.game.tweens.add(tween); }; return GameObjectFactory; })(); @@ -13522,7 +13514,7 @@ var Phaser; * @type {number} */ this.maxIterations = 10; - this._game = game; + this.game = game; this.enterLandscape = new Phaser.Signal(); this.enterPortrait = new Phaser.Signal(); if(window['orientation']) { @@ -13565,7 +13557,7 @@ var Phaser; if(this.isFullScreen) { return; } - var element = this._game.stage.canvas; + var element = this.game.stage.canvas; if(element['requestFullScreen']) { element['requestFullScreen'](); } else if(element['mozRequestFullScreen']) { @@ -13587,7 +13579,7 @@ var Phaser; * The core update loop, called by Phaser.Stage */ function () { - if(this._game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height)) { + if(this.game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height)) { this.refresh(); } if(this.forceLandscape || this.forcePortrait) { @@ -13599,14 +13591,14 @@ var Phaser; if(this.incorrectOrientation) { if((this.forceLandscape && window.innerWidth > window.innerHeight) || (this.forcePortrait && window.innerHeight > window.innerWidth)) { // Back to normal - this._game.paused = false; + this.game.paused = false; this.incorrectOrientation = false; this.refresh(); } } else { if((this.forceLandscape && window.innerWidth < window.innerHeight) || (this.forcePortrait && window.innerHeight < window.innerWidth)) { // Show orientation screen - this._game.paused = true; + this.game.paused = true; this.incorrectOrientation = true; this.refresh(); } @@ -13636,7 +13628,7 @@ var Phaser; } else { this.enterPortrait.dispatch(this.orientation, false, true); } - if(this._game.stage.scaleMode !== StageScaleMode.NO_SCALE) { + if(this.game.stage.scaleMode !== StageScaleMode.NO_SCALE) { this.refresh(); } }; @@ -13654,7 +13646,7 @@ var Phaser; } else { this.enterPortrait.dispatch(this.orientation, false, true); } - if(this._game.stage.scaleMode !== StageScaleMode.NO_SCALE) { + if(this.game.stage.scaleMode !== StageScaleMode.NO_SCALE) { this.refresh(); } }; @@ -13664,10 +13656,10 @@ var Phaser; function () { var _this = this; // We can't do anything about the status bars in iPads, web apps or desktops - if(this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false) { + if(this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false) { document.documentElement.style.minHeight = '2000px'; this._startHeight = window.innerHeight; - if(this._game.device.android && this._game.device.chrome == false) { + if(this.game.device.android && this.game.device.chrome == false) { window.scrollTo(0, 1); } else { window.scrollTo(0, 0); @@ -13686,8 +13678,8 @@ var Phaser; */ function (force) { if (typeof force === "undefined") { force = false; } - if(this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false) { - if(this._game.device.android && this._game.device.chrome == false) { + if(this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false) { + if(this.game.device.android && this.game.device.chrome == false) { window.scrollTo(0, 1); } else { window.scrollTo(0, 0); @@ -13699,9 +13691,9 @@ var Phaser; document.documentElement.style.minHeight = window.innerHeight + 'px'; if(this.incorrectOrientation == true) { this.setMaximum(); - } else if(this._game.stage.scaleMode == StageScaleMode.EXACT_FIT) { + } else if(this.game.stage.scaleMode == StageScaleMode.EXACT_FIT) { this.setExactFit(); - } else if(this._game.stage.scaleMode == StageScaleMode.SHOW_ALL) { + } else if(this.game.stage.scaleMode == StageScaleMode.SHOW_ALL) { this.setShowAll(); } this.setSize(); @@ -13724,36 +13716,36 @@ var Phaser; this.height = this.minHeight; } } - this._game.stage.canvas.style.width = this.width + 'px'; - this._game.stage.canvas.style.height = this.height + 'px'; - this._game.input.scale.setTo(this._game.stage.width / this.width, this._game.stage.height / this.height); + this.game.stage.canvas.style.width = this.width + 'px'; + this.game.stage.canvas.style.height = this.height + 'px'; + this.game.input.scale.setTo(this.game.stage.width / this.width, this.game.stage.height / this.height); if(this.pageAlignHorizontally) { if(this.width < window.innerWidth && this.incorrectOrientation == false) { - this._game.stage.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px'; + this.game.stage.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px'; } else { - this._game.stage.canvas.style.marginLeft = '0px'; + this.game.stage.canvas.style.marginLeft = '0px'; } } if(this.pageAlignVeritcally) { if(this.height < window.innerHeight && this.incorrectOrientation == false) { - this._game.stage.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px'; + this.game.stage.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px'; } else { - this._game.stage.canvas.style.marginTop = '0px'; + this.game.stage.canvas.style.marginTop = '0px'; } } - this._game.stage.getOffset(this._game.stage.canvas); + this.game.stage.getOffset(this.game.stage.canvas); this.aspectRatio = this.width / this.height; - this.scaleFactor.x = this._game.stage.width / this.width; - this.scaleFactor.y = this._game.stage.height / this.height; + this.scaleFactor.x = this.game.stage.width / this.width; + this.scaleFactor.y = this.game.stage.height / this.height; }; StageScaleMode.prototype.setMaximum = function () { this.width = window.innerWidth; this.height = window.innerHeight; }; StageScaleMode.prototype.setShowAll = function () { - var multiplier = Math.min((window.innerHeight / this._game.stage.height), (window.innerWidth / this._game.stage.width)); - this.width = Math.round(this._game.stage.width * multiplier); - this.height = Math.round(this._game.stage.height * multiplier); + var multiplier = Math.min((window.innerHeight / this.game.stage.height), (window.innerWidth / this.game.stage.width)); + this.width = Math.round(this.game.stage.width * multiplier); + this.height = Math.round(this.game.stage.height * multiplier); }; StageScaleMode.prototype.setExactFit = function () { if(this.maxWidth && window.innerWidth > this.maxWidth) { @@ -13813,7 +13805,7 @@ var Phaser; * @type {Phaser.Tween} */ this._fade = null; - this._game = game; + this.game = game; this._logo = new Image(); this._logo.src = this._logoData; } @@ -13835,36 +13827,36 @@ var Phaser; * Render BootScreen. */ function () { - var grd = this._game.stage.context.createLinearGradient(0, 0, 0, this._game.stage.height); + var grd = this.game.stage.context.createLinearGradient(0, 0, 0, this.game.stage.height); grd.addColorStop(0, 'rgb(' + this._color1.r + ', ' + this._color1.g + ', ' + this._color1.b + ')'); grd.addColorStop(0.5, 'rgb(' + this._color2.r + ', ' + this._color2.g + ', ' + this._color2.b + ')'); grd.addColorStop(1, 'rgb(' + this._color1.r + ', ' + this._color1.g + ', ' + this._color1.b + ')'); - this._game.stage.context.fillStyle = grd; - this._game.stage.context.fillRect(0, 0, this._game.stage.width, this._game.stage.height); - this._game.stage.context.shadowOffsetX = 0; - this._game.stage.context.shadowOffsetY = 0; + this.game.stage.context.fillStyle = grd; + this.game.stage.context.fillRect(0, 0, this.game.stage.width, this.game.stage.height); + this.game.stage.context.shadowOffsetX = 0; + this.game.stage.context.shadowOffsetY = 0; if(this._logo) { - this._game.stage.context.drawImage(this._logo, 32, 32); + this.game.stage.context.drawImage(this._logo, 32, 32); } - this._game.stage.context.shadowColor = 'rgb(0,0,0)'; - this._game.stage.context.shadowOffsetX = 1; - this._game.stage.context.shadowOffsetY = 1; - this._game.stage.context.shadowBlur = 0; - this._game.stage.context.fillStyle = 'rgb(255,255,255)'; - this._game.stage.context.font = 'bold 18px Arial'; - this._game.stage.context.textBaseline = 'top'; - this._game.stage.context.fillText(Phaser.VERSION, 32, 64 + 32); - this._game.stage.context.fillText('Game Size: ' + this._game.stage.width + ' x ' + this._game.stage.height, 32, 64 + 64); - this._game.stage.context.fillText('www.photonstorm.com', 32, 64 + 96); - this._game.stage.context.font = '16px Arial'; - this._game.stage.context.fillText('You are seeing this screen because you didn\'t specify any default', 32, 64 + 160); - this._game.stage.context.fillText('functions in the Game constructor or use Game.switchState()', 32, 64 + 184); + this.game.stage.context.shadowColor = 'rgb(0,0,0)'; + this.game.stage.context.shadowOffsetX = 1; + this.game.stage.context.shadowOffsetY = 1; + this.game.stage.context.shadowBlur = 0; + this.game.stage.context.fillStyle = 'rgb(255,255,255)'; + this.game.stage.context.font = 'bold 18px Arial'; + this.game.stage.context.textBaseline = 'top'; + this.game.stage.context.fillText(Phaser.VERSION, 32, 64 + 32); + this.game.stage.context.fillText('Game Size: ' + this.game.stage.width + ' x ' + this.game.stage.height, 32, 64 + 64); + this.game.stage.context.fillText('www.photonstorm.com', 32, 64 + 96); + this.game.stage.context.font = '16px Arial'; + this.game.stage.context.fillText('You are seeing this screen because you didn\'t specify any default', 32, 64 + 160); + this.game.stage.context.fillText('functions in the Game constructor or use Game.switchState()', 32, 64 + 184); }; BootScreen.prototype.colorCycle = /** * Start color fading cycle. */ function () { - this._fade = this._game.add.tween(this._color2); + this._fade = this.game.add.tween(this._color2); this._fade.to({ r: Math.random() * 250, g: Math.random() * 250, @@ -13894,7 +13886,7 @@ var Phaser; * @param height {number} Screen canvas height. */ function PauseScreen(game, width, height) { - this._game = game; + this.game = game; this._canvas = document.createElement('canvas'); this._canvas.width = width; this._canvas.height = height; @@ -13906,7 +13898,7 @@ var Phaser; function () { // Take a grab of the current canvas to our temporary one this._context.clearRect(0, 0, this._canvas.width, this._canvas.height); - this._context.drawImage(this._game.stage.canvas, 0, 0); + this._context.drawImage(this.game.stage.canvas, 0, 0); this._color = { r: 255, g: 255, @@ -13919,7 +13911,7 @@ var Phaser; */ function () { this._fade.stop(); - this._game.tweens.remove(this._fade); + this.game.tweens.remove(this._fade); }; PauseScreen.prototype.update = /** * Update background color. @@ -13933,27 +13925,27 @@ var Phaser; * Render PauseScreen. */ function () { - this._game.stage.context.drawImage(this._canvas, 0, 0); - this._game.stage.context.fillStyle = 'rgba(0, 0, 0, 0.4)'; - this._game.stage.context.fillRect(0, 0, this._game.stage.width, this._game.stage.height); + this.game.stage.context.drawImage(this._canvas, 0, 0); + this.game.stage.context.fillStyle = 'rgba(0, 0, 0, 0.4)'; + this.game.stage.context.fillRect(0, 0, this.game.stage.width, this.game.stage.height); // Draw a 'play' arrow - var arrowWidth = Math.round(this._game.stage.width / 2); - var arrowHeight = Math.round(this._game.stage.height / 2); - var sx = this._game.stage.centerX - arrowWidth / 2; - var sy = this._game.stage.centerY - arrowHeight / 2; - this._game.stage.context.beginPath(); - this._game.stage.context.moveTo(sx, sy); - this._game.stage.context.lineTo(sx, sy + arrowHeight); - this._game.stage.context.lineTo(sx + arrowWidth, this._game.stage.centerY); - this._game.stage.context.fillStyle = 'rgba(' + this._color.r + ', ' + this._color.g + ', ' + this._color.b + ', 0.8)'; - this._game.stage.context.fill(); - this._game.stage.context.closePath(); + var arrowWidth = Math.round(this.game.stage.width / 2); + var arrowHeight = Math.round(this.game.stage.height / 2); + var sx = this.game.stage.centerX - arrowWidth / 2; + var sy = this.game.stage.centerY - arrowHeight / 2; + this.game.stage.context.beginPath(); + this.game.stage.context.moveTo(sx, sy); + this.game.stage.context.lineTo(sx, sy + arrowHeight); + this.game.stage.context.lineTo(sx + arrowWidth, this.game.stage.centerY); + this.game.stage.context.fillStyle = 'rgba(' + this._color.r + ', ' + this._color.g + ', ' + this._color.b + ', 0.8)'; + this.game.stage.context.fill(); + this.game.stage.context.closePath(); }; PauseScreen.prototype.fadeOut = /** * Start fadeOut effect. */ function () { - this._fade = this._game.add.tween(this._color); + this._fade = this.game.add.tween(this._color); this._fade.to({ r: 50, g: 50, @@ -13966,7 +13958,7 @@ var Phaser; * Start fadeIn effect. */ function () { - this._fade = this._game.add.tween(this._color); + this._fade = this.game.add.tween(this._color); this._fade.to({ r: 255, g: 255, @@ -14079,13 +14071,7 @@ var Phaser; * @type {boolean} */ this.disableVisibilityChange = false; - /** - * An optional 'fix' for the horrendous Android stock browser bug - * https://code.google.com/p/android/issues/detail?id=39247 - * @type {boolean} - */ - this.patchAndroidClearRectBug = false; - this._game = game; + this.game = game; this.canvas = document.createElement('canvas'); this.canvas.width = width; this.canvas.height = height; @@ -14106,7 +14092,7 @@ var Phaser; this.context = this.canvas.getContext('2d'); this.css3 = new Phaser.Display.CSS3Filters(this.canvas); this.scaleMode = Phaser.StageScaleMode.NO_SCALE; - this.scale = new Phaser.StageScaleMode(this._game, width, height); + this.scale = new Phaser.StageScaleMode(this.game, width, height); this.getOffset(this.canvas); this.bounds = new Phaser.Rectangle(this.offset.x, this.offset.y, width, height); this.aspectRatio = width / height; @@ -14133,9 +14119,9 @@ var Phaser; * Stage boot */ function () { - this.bootScreen = new Phaser.BootScreen(this._game); - this.pauseScreen = new Phaser.PauseScreen(this._game, this.width, this.height); - this.orientationScreen = new Phaser.OrientationScreen(this._game); + this.bootScreen = new Phaser.BootScreen(this.game); + this.pauseScreen = new Phaser.PauseScreen(this.game, this.width, this.height); + this.orientationScreen = new Phaser.OrientationScreen(this.game); this.scale.setScreenSize(true); }; Stage.prototype.update = /** @@ -14145,24 +14131,24 @@ var Phaser; function () { this.scale.update(); this.context.setTransform(1, 0, 0, 1, 0, 0); - if(this.clear || (this._game.paused && this.disablePauseScreen == false)) { - if(this.patchAndroidClearRectBug) { + if(this.clear || (this.game.paused && this.disablePauseScreen == false)) { + if(this.game.device.patchAndroidClearRectBug) { this.context.fillStyle = 'rgb(0,0,0)'; this.context.fillRect(0, 0, this.width, this.height); } else { this.context.clearRect(0, 0, this.width, this.height); } } - if(this._game.paused && this.scale.incorrectOrientation) { + if(this.game.paused && this.scale.incorrectOrientation) { this.orientationScreen.update(); this.orientationScreen.render(); return; } - if(this._game.isRunning == false && this.disableBootScreen == false) { + if(this.game.isRunning == false && this.disableBootScreen == false) { this.bootScreen.update(); this.bootScreen.render(); } - if(this._game.paused && this.disablePauseScreen == false) { + if(this.game.paused && this.disablePauseScreen == false) { this.pauseScreen.update(); this.pauseScreen.render(); } @@ -14175,11 +14161,11 @@ var Phaser; return; } if(event.type == 'pagehide' || event.type == 'blur' || document['hidden'] == true || document['webkitHidden'] == true) { - if(this._game.paused == false) { + if(this.game.paused == false) { this.pauseGame(); } } else { - if(this._game.paused == true) { + if(this.game.paused == true) { this.resumeGame(); } } @@ -14192,7 +14178,7 @@ var Phaser; if(forceLandscape || forcePortrait) { if((this.scale.isLandscape && forcePortrait) || (this.scale.isPortrait && forceLandscape)) { // They are in the wrong orientation right now - this._game.paused = true; + this.game.paused = true; this.scale.incorrectOrientation = true; } else { this.scale.incorrectOrientation = false; @@ -14210,14 +14196,14 @@ var Phaser; this.pauseScreen.onPaused(); } this.saveCanvasValues(); - this._game.paused = true; + this.game.paused = true; }; Stage.prototype.resumeGame = function () { if(this.disablePauseScreen == false && this.pauseScreen) { this.pauseScreen.onResume(); } this.restoreCanvasValues(); - this._game.paused = false; + this.game.paused = false; }; Stage.prototype.getOffset = /** * Get the DOM offset values of the given element @@ -14251,7 +14237,7 @@ var Phaser; this.context.strokeStyle = this.strokeStyle; this.context.lineWidth = this.lineWidth; this.context.fillStyle = this.fillStyle; - if(this.patchAndroidClearRectBug) { + if(this.game.device.patchAndroidClearRectBug) { this.context.fillStyle = 'rgb(0,0,0)'; this.context.fillRect(0, 0, this.width, this.height); } else { @@ -14499,7 +14485,7 @@ var Phaser; * @param game {Game} A reference to the current Game. */ function TweenManager(game) { - this._game = game; + this.game = game; this._tweens = []; } TweenManager.prototype.getAll = /** @@ -14525,10 +14511,10 @@ var Phaser; function (object, localReference) { if (typeof localReference === "undefined") { localReference = false; } if(localReference) { - object['tween'] = new Phaser.Tween(object, this._game); + object['tween'] = new Phaser.Tween(object, this.game); return object['tween']; } else { - return new Phaser.Tween(object, this._game); + return new Phaser.Tween(object, this.game); } }; TweenManager.prototype.add = /** @@ -14538,7 +14524,7 @@ var Phaser; * @return {Phaser.Tween} The tween object you added to the manager. */ function (tween) { - tween.parent = this._game; + tween.parent = this.game; this._tweens.push(tween); return tween; }; @@ -14565,7 +14551,7 @@ var Phaser; var i = 0; var numTweens = this._tweens.length; while(i < numTweens) { - if(this._tweens[i].update(this._game.time.now)) { + if(this._tweens[i].update(this.game.time.now)) { i++; } else { this._tweens.splice(i, 1); @@ -14637,8 +14623,8 @@ var Phaser; * @type {Group} */ this._groupCounter = 0; - this._game = game; - this.cameras = new Phaser.CameraManager(this._game, 0, 0, width, height); + this.game = game; + this.cameras = new Phaser.CameraManager(this.game, 0, 0, width, height); this.bounds = new Phaser.Rectangle(0, 0, width, height); } World.prototype.getNextGroupID = function () { @@ -14648,7 +14634,7 @@ var Phaser; * Called once by Game during the boot process. */ function () { - this.group = new Phaser.Group(this._game, 0); + this.group = new Phaser.Group(this.game, 0); }; World.prototype.update = /** * This is called automatically every frame, and is where main logic happens. @@ -14683,7 +14669,7 @@ var Phaser; this.bounds.width = width; this.bounds.height = height; if(updateCameraBounds == true) { - this._game.camera.setBounds(0, 0, width, height); + this.game.camera.setBounds(0, 0, width, height); } // dispatch world resize event }; @@ -14761,6 +14747,13 @@ var Phaser; * Device constructor */ function Device() { + // Android bug specific :) + /** + * An optional 'fix' for the horrendous Android stock browser bug + * https://code.google.com/p/android/issues/detail?id=39247 + * @type {boolean} + */ + this.patchAndroidClearRectBug = false; // Operating System /** * Is running desktop? @@ -15221,7 +15214,7 @@ var Phaser; * @type Boolean **/ this.isRunning = false; - this._game = game; + this.game = game; this.callback = callback; var vendors = [ 'ms', @@ -15295,9 +15288,9 @@ var Phaser; **/ function (time) { var _this = this; - this._game.time.update(time); + this.game.time.update(time); if(this.callback) { - this.callback.call(this._game); + this.callback.call(this.game); } this._onLoop = function (time) { return _this.RAFUpdate(time); @@ -15310,13 +15303,13 @@ var Phaser; **/ function () { var _this = this; - this._game.time.update(Date.now()); + this.game.time.update(Date.now()); this._onLoop = function () { return _this.SetTimeoutUpdate(); }; this._timeOutID = window.setTimeout(this._onLoop, 16); if(this.callback) { - this.callback.call(this._game); + this.callback.call(this.game); } }; return RequestAnimationFrame; @@ -15824,6 +15817,9 @@ var Phaser; * @param {Any} event */ function (event) { + if(this.game.input.pollLocked) { + return; + } if(event.button) { this.button = event.button; } @@ -16133,20 +16129,20 @@ var Phaser; * @return {Touch} This object. */ function Gestures(game) { - this._game = game; + this.game = game; } Gestures.prototype.start = function () { // Local references to the Phaser.Input.pointer objects - this._p1 = this._game.input.pointer1; - this._p2 = this._game.input.pointer2; - this._p3 = this._game.input.pointer3; - this._p4 = this._game.input.pointer4; - this._p5 = this._game.input.pointer5; - this._p6 = this._game.input.pointer6; - this._p7 = this._game.input.pointer7; - this._p8 = this._game.input.pointer8; - this._p9 = this._game.input.pointer9; - this._p10 = this._game.input.pointer10; + this._p1 = this.game.input.pointer1; + this._p2 = this.game.input.pointer2; + this._p3 = this.game.input.pointer3; + this._p4 = this.game.input.pointer4; + this._p5 = this.game.input.pointer5; + this._p6 = this.game.input.pointer6; + this._p7 = this.game.input.pointer7; + this._p8 = this.game.input.pointer8; + this._p9 = this.game.input.pointer9; + this._p10 = this.game.input.pointer10; }; return Gestures; })(); @@ -16723,6 +16719,13 @@ var Phaser; (function (Phaser) { var InputManager = (function () { function InputManager(game) { + /** + * How often should the input pointers be checked for updates? + * A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on. + * @type {number} + */ + this.pollRate = 0; + this._pollCounter = 0; /** * A vector object representing the previous position of the Pointer. * @property vector @@ -17031,11 +17034,22 @@ var Phaser; this.inputObjects[index] = null; } }; + Object.defineProperty(InputManager.prototype, "pollLocked", { + get: function () { + return (this.pollRate > 0 && this._pollCounter < this.pollRate); + }, + enumerable: true, + configurable: true + }); InputManager.prototype.update = /** * Updates the Input Manager. Called by the core Game loop. * @method update **/ function () { + if(this.pollRate > 0 && this._pollCounter < this.pollRate) { + this._pollCounter++; + return; + } this.speed.x = this.position.x - this._oldPosition.x; this.speed.y = this.position.y - this._oldPosition.y; this._oldPosition.copyFrom(this.position); @@ -17066,6 +17080,7 @@ var Phaser; if(this.pointer10) { this.pointer10.update(); } + this._pollCounter = 0; }; InputManager.prototype.reset = /** * Reset all of the Pointers and Input states @@ -17100,6 +17115,7 @@ var Phaser; this.inputObjects.length = 0; this.totalTrackedObjects = 0; } + this._pollCounter = 0; }; InputManager.prototype.resetSpeed = function (x, y) { this._oldPosition.setTo(x, y); @@ -17347,7 +17363,12 @@ var Phaser; if(camera.visible == false || camera.transform.scale.x == 0 || camera.transform.scale.y == 0 || camera.texture.alpha < 0.1) { return false; } - camera.texture.context.clearRect(0, 0, camera.width, camera.height); + if(this.game.device.patchAndroidClearRectBug) { + camera.texture.context.fillStyle = 'rgb(0,0,0)'; + camera.texture.context.fillRect(0, 0, camera.width, camera.height); + } else { + camera.texture.context.clearRect(0, 0, camera.width, camera.height); + } // Alpha if(camera.texture.alpha !== 1 && camera.texture.context.globalAlpha != camera.texture.alpha) { this._ga = camera.texture.context.globalAlpha; @@ -18381,17 +18402,17 @@ var Phaser; * @param parent {string} ID of its parent DOM element. * @param width {number} The width of your game in game pixels. * @param height {number} The height of your game in game pixels. - * @param initCallback {function} Init callback invoked when init default screen. + * @param preloadCallback {function} Preload callback invoked when init default screen. * @param createCallback {function} Create callback invoked when create default screen. * @param updateCallback {function} Update callback invoked when update default screen. * @param renderCallback {function} Render callback invoked when render default screen. * @param destroyCallback {function} Destroy callback invoked when state is destroyed. */ - function Game(callbackContext, parent, width, height, initCallback, createCallback, updateCallback, renderCallback, destroyCallback) { + function Game(callbackContext, parent, width, height, preloadCallback, createCallback, updateCallback, renderCallback, destroyCallback) { if (typeof parent === "undefined") { parent = ''; } if (typeof width === "undefined") { width = 800; } if (typeof height === "undefined") { height = 600; } - if (typeof initCallback === "undefined") { initCallback = null; } + if (typeof preloadCallback === "undefined") { preloadCallback = null; } if (typeof createCallback === "undefined") { createCallback = null; } if (typeof updateCallback === "undefined") { updateCallback = null; } if (typeof renderCallback === "undefined") { renderCallback = null; } @@ -18401,7 +18422,7 @@ var Phaser; * Milliseconds of time per step of the game loop. * @type {number} */ - this._step = 0; + //private _step: number = 0; /** * Whether load complete loading or not. * @type {boolean} @@ -18426,7 +18447,7 @@ var Phaser; * This will be called when init states. (loading assets...) * @type {function} */ - this.onInitCallback = null; + this.onPreloadCallback = null; /** * This will be called when create states. (setup states...) * @type {function} @@ -18479,7 +18500,7 @@ var Phaser; this.isRunning = false; this.id = Phaser.GAMES.push(this) - 1; this.callbackContext = callbackContext; - this.onInitCallback = initCallback; + this.onPreloadCallback = preloadCallback; this.onCreateCallback = createCallback; this.onUpdateCallback = updateCallback; this.onRenderCallback = renderCallback; @@ -18518,7 +18539,7 @@ var Phaser; this.world = new Phaser.World(this, width, height); this.add = new Phaser.GameObjectFactory(this); this.cache = new Phaser.Cache(this); - this.load = new Phaser.Loader(this, this.loadComplete); + this.load = new Phaser.Loader(this); this.time = new Phaser.TimeManager(this); this.tweens = new Phaser.TweenManager(this); this.input = new Phaser.InputManager(this); @@ -18528,6 +18549,7 @@ var Phaser; ]); this.physics = new Phaser.Physics.Manager(this); this.plugins = new Phaser.PluginManager(this, this); + this.load.onLoadComplete.addOnce(this.loadComplete, this); this.setRenderer(Phaser.Types.RENDERER_CANVAS); this.world.boot(); this.stage.boot(); @@ -18538,7 +18560,7 @@ var Phaser; Phaser.ColorUtils.game = this; Phaser.DebugUtils.context = this.stage.context; // Display the default game screen? - if(this.onInitCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null) { + if(this.onPreloadCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null) { this._raf = new Phaser.RequestAnimationFrame(this, this.bootLoop); } else { this.isRunning = true; @@ -18565,10 +18587,11 @@ var Phaser; } }; Game.prototype.loadComplete = /** - * Called when the load has finished after init was run. + * Called when the load has finished after preload was run. */ function () { this._loadComplete = true; + this.onCreateCallback.call(this.callbackContext); }; Game.prototype.bootLoop = /** * The bootLoop is called while the game is still booting (waiting for the DOM and resources to be available) @@ -18629,15 +18652,18 @@ var Phaser; * Start current state. */ function () { - if(this.onInitCallback !== null) { + if(this.onPreloadCallback !== null) { this.load.reset(); - this.onInitCallback.call(this.callbackContext); - // Is the load empty? + this.onPreloadCallback.call(this.callbackContext); + // Is the loader empty? if(this.load.queueSize == 0) { if(this.onCreateCallback !== null) { this.onCreateCallback.call(this.callbackContext); } this._loadComplete = true; + } else { + // Start the loader going as we have something in the queue + this.load.start(); } } else { // No init? Then there was nothing to load either @@ -18649,19 +18675,19 @@ var Phaser; }; Game.prototype.setCallbacks = /** * Set the most common state callbacks (init, create, update, render). - * @param initCallback {function} Init callback invoked when init state. + * @param preloadCallback {function} Init callback invoked when init state. * @param createCallback {function} Create callback invoked when create state. * @param updateCallback {function} Update callback invoked when update state. * @param renderCallback {function} Render callback invoked when render state. * @param destroyCallback {function} Destroy callback invoked when state is destroyed. */ - function (initCallback, createCallback, updateCallback, renderCallback, destroyCallback) { - if (typeof initCallback === "undefined") { initCallback = null; } + function (preloadCallback, createCallback, updateCallback, renderCallback, destroyCallback) { + if (typeof preloadCallback === "undefined") { preloadCallback = null; } if (typeof createCallback === "undefined") { createCallback = null; } if (typeof updateCallback === "undefined") { updateCallback = null; } if (typeof renderCallback === "undefined") { renderCallback = null; } if (typeof destroyCallback === "undefined") { destroyCallback = null; } - this.onInitCallback = initCallback; + this.onPreloadCallback = preloadCallback; this.onCreateCallback = createCallback; this.onUpdateCallback = updateCallback; this.onRenderCallback = renderCallback; @@ -18692,7 +18718,7 @@ var Phaser; // Ok, have we got the right functions? if(this.state['create'] || this.state['update']) { this.callbackContext = this.state; - this.onInitCallback = null; + this.onPreloadCallback = null; this.onLoadRenderCallback = null; this.onLoadUpdateCallback = null; this.onCreateCallback = null; @@ -18702,8 +18728,8 @@ var Phaser; this.onPausedCallback = null; this.onDestroyCallback = null; // Bingo, let's set them up - if(this.state['init']) { - this.onInitCallback = this.state['init']; + if(this.state['preload']) { + this.onPreloadCallback = this.state['preload']; } if(this.state['loadRender']) { this.onLoadRenderCallback = this.state['loadRender']; @@ -18746,7 +18772,7 @@ var Phaser; */ function () { this.callbackContext = null; - this.onInitCallback = null; + this.onPreloadCallback = null; this.onLoadRenderCallback = null; this.onLoadUpdateCallback = null; this.onCreateCallback = null; @@ -18819,7 +18845,7 @@ var Phaser; * @param looped {boolean} Whether or not the animation is looped or just plays once. */ function Animation(game, parent, frameData, name, frames, delay, looped) { - this._game = game; + this.game = game; this._parent = parent; this._frames = frames; this._frameData = frameData; @@ -18872,8 +18898,8 @@ var Phaser; } this.isPlaying = true; this.isFinished = false; - this._timeLastFrame = this._game.time.now; - this._timeNextFrame = this._game.time.now + this.delay; + this._timeLastFrame = this.game.time.now; + this._timeNextFrame = this.game.time.now + this.delay; this._frameIndex = 0; this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); this._parent.events.onAnimationStart.dispatch(this._parent, this); @@ -18885,8 +18911,8 @@ var Phaser; function () { this.isPlaying = true; this.isFinished = false; - this._timeLastFrame = this._game.time.now; - this._timeNextFrame = this._game.time.now + this.delay; + this._timeLastFrame = this.game.time.now; + this._timeNextFrame = this.game.time.now + this.delay; this._frameIndex = 0; this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); }; @@ -18901,7 +18927,7 @@ var Phaser; * Update animation frames. */ function () { - if(this.isPlaying == true && this._game.time.now >= this._timeNextFrame) { + if(this.isPlaying == true && this.game.time.now >= this._timeNextFrame) { this._frameIndex++; if(this._frameIndex == this._frames.length) { if(this.looped) { @@ -18914,8 +18940,8 @@ var Phaser; } else { this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); } - this._timeLastFrame = this._game.time.now; - this._timeNextFrame = this._game.time.now + this.delay; + this._timeLastFrame = this.game.time.now; + this._timeNextFrame = this.game.time.now + this.delay; return true; } return false; @@ -18924,7 +18950,7 @@ var Phaser; * Clean up animation memory. */ function () { - this._game = null; + this.game = null; this._parent = null; this._frames = null; this._frameData = null; diff --git a/Tests/scrollzones/ballscroller.js b/Tests/scrollzones/ballscroller.js index 007a74da..bdda1a84 100644 --- a/Tests/scrollzones/ballscroller.js +++ b/Tests/scrollzones/ballscroller.js @@ -1,10 +1,9 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.image('balls', 'assets/sprites/balls.png'); - game.load.start(); } var scroller; function create() { diff --git a/Tests/scrollzones/ballscroller.ts b/Tests/scrollzones/ballscroller.ts index 44f4e303..f6df3cec 100644 --- a/Tests/scrollzones/ballscroller.ts +++ b/Tests/scrollzones/ballscroller.ts @@ -3,13 +3,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.image('balls', 'assets/sprites/balls.png'); - game.load.start(); + } diff --git a/Tests/scrollzones/blasteroids.js b/Tests/scrollzones/blasteroids.js index 7d2ca1cd..b5d954b8 100644 --- a/Tests/scrollzones/blasteroids.js +++ b/Tests/scrollzones/blasteroids.js @@ -1,13 +1,12 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.load.image('nashwan', 'assets/sprites/xenon2_ship.png'); game.load.image('starfield', 'assets/misc/starfield.jpg'); game.load.image('jet', 'assets/sprites/particle1.png'); game.load.image('bullet', 'assets/misc/bullet1.png'); - game.load.start(); } var scroller; var emitter; diff --git a/Tests/scrollzones/blasteroids.ts b/Tests/scrollzones/blasteroids.ts index 19d56d54..266e623d 100644 --- a/Tests/scrollzones/blasteroids.ts +++ b/Tests/scrollzones/blasteroids.ts @@ -3,16 +3,16 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.load.image('nashwan', 'assets/sprites/xenon2_ship.png'); game.load.image('starfield', 'assets/misc/starfield.jpg'); game.load.image('jet', 'assets/sprites/particle1.png'); game.load.image('bullet', 'assets/misc/bullet1.png'); - game.load.start(); + } diff --git a/Tests/scrollzones/parallax.js b/Tests/scrollzones/parallax.js index 8d4c21fa..6e65a7e8 100644 --- a/Tests/scrollzones/parallax.js +++ b/Tests/scrollzones/parallax.js @@ -1,10 +1,9 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { game.load.image('starray', 'assets/pics/auto_scroll_landscape.png'); - game.load.start(); } function create() { var zone = game.add.scrollZone('starray'); diff --git a/Tests/scrollzones/parallax.ts b/Tests/scrollzones/parallax.ts index f50a32fe..0d9d5806 100644 --- a/Tests/scrollzones/parallax.ts +++ b/Tests/scrollzones/parallax.ts @@ -3,13 +3,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.image('starray', 'assets/pics/auto_scroll_landscape.png'); - game.load.start(); + } diff --git a/Tests/scrollzones/region demo.js b/Tests/scrollzones/region demo.js index a93d8ce8..8caff26b 100644 --- a/Tests/scrollzones/region demo.js +++ b/Tests/scrollzones/region demo.js @@ -1,10 +1,9 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { game.load.image('angelDawn', 'assets/pics/game14_angel_dawn.png'); - game.load.start(); } var scroller; function create() { diff --git a/Tests/scrollzones/region demo.ts b/Tests/scrollzones/region demo.ts index 0a7e3073..d32b9922 100644 --- a/Tests/scrollzones/region demo.ts +++ b/Tests/scrollzones/region demo.ts @@ -3,13 +3,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.image('angelDawn', 'assets/pics/game14_angel_dawn.png'); - game.load.start(); + } diff --git a/Tests/scrollzones/scroll window.js b/Tests/scrollzones/scroll window.js index dc255014..59c74ee1 100644 --- a/Tests/scrollzones/scroll window.js +++ b/Tests/scrollzones/scroll window.js @@ -1,11 +1,10 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { game.load.image('dragonsun', 'assets/pics/cougar_dragonsun.png'); game.load.image('overlay', 'assets/pics/scrollframe.png'); - game.load.start(); } var scroller; function create() { diff --git a/Tests/scrollzones/scroll window.ts b/Tests/scrollzones/scroll window.ts index 07863017..eb57e7b4 100644 --- a/Tests/scrollzones/scroll window.ts +++ b/Tests/scrollzones/scroll window.ts @@ -3,14 +3,14 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.image('dragonsun', 'assets/pics/cougar_dragonsun.png'); game.load.image('overlay', 'assets/pics/scrollframe.png'); - game.load.start(); + } diff --git a/Tests/scrollzones/simple scrollzone.js b/Tests/scrollzones/simple scrollzone.js index 71bb8643..3f958cd4 100644 --- a/Tests/scrollzones/simple scrollzone.js +++ b/Tests/scrollzones/simple scrollzone.js @@ -1,10 +1,9 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { game.load.image('crystal', 'assets/pics/jim_sachs_time_crystal.png'); - game.load.start(); } function create() { // This creates our ScrollZone. It is positioned at x0 y0 (world coodinates) by default and uses diff --git a/Tests/scrollzones/simple scrollzone.ts b/Tests/scrollzones/simple scrollzone.ts index c0fc83a9..1573ecad 100644 --- a/Tests/scrollzones/simple scrollzone.ts +++ b/Tests/scrollzones/simple scrollzone.ts @@ -3,12 +3,12 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.image('crystal', 'assets/pics/jim_sachs_time_crystal.png'); - game.load.start(); + } diff --git a/Tests/scrollzones/skewed scroller.js b/Tests/scrollzones/skewed scroller.js index 6e4ebabf..81c0c76f 100644 --- a/Tests/scrollzones/skewed scroller.js +++ b/Tests/scrollzones/skewed scroller.js @@ -1,10 +1,9 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { game.load.image('balls', 'assets/sprites/balls.png'); - game.load.start(); } var leftFace; var rightFace; diff --git a/Tests/scrollzones/skewed scroller.ts b/Tests/scrollzones/skewed scroller.ts index 4a3c3d10..ede7f1de 100644 --- a/Tests/scrollzones/skewed scroller.ts +++ b/Tests/scrollzones/skewed scroller.ts @@ -3,12 +3,12 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.image('balls', 'assets/sprites/balls.png'); - game.load.start(); + } diff --git a/Tests/sprites/alpha.js b/Tests/sprites/alpha.js index c462970f..c8faf964 100644 --- a/Tests/sprites/alpha.js +++ b/Tests/sprites/alpha.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('bunny', 'assets/sprites/bunny.png'); - game.load.start(); } function create() { // Here we'll assign the new sprite to the local bunny variable diff --git a/Tests/sprites/alpha.ts b/Tests/sprites/alpha.ts index 9cea6b8b..76db8806 100644 --- a/Tests/sprites/alpha.ts +++ b/Tests/sprites/alpha.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('bunny', 'assets/sprites/bunny.png'); - game.load.start(); + } diff --git a/Tests/sprites/animate by framename.js b/Tests/sprites/animate by framename.js index ac6baf84..f71e1e05 100644 --- a/Tests/sprites/animate by framename.js +++ b/Tests/sprites/animate by framename.js @@ -1,9 +1,8 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json'); - game.load.start(); } var bot; function create() { diff --git a/Tests/sprites/animate by framename.ts b/Tests/sprites/animate by framename.ts index 47581718..ce738ced 100644 --- a/Tests/sprites/animate by framename.ts +++ b/Tests/sprites/animate by framename.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json'); - game.load.start(); + } diff --git a/Tests/sprites/animation 1.js b/Tests/sprites/animation 1.js index eb481565..ed5f3d57 100644 --- a/Tests/sprites/animation 1.js +++ b/Tests/sprites/animation 1.js @@ -1,12 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder // The sprite sheet is a standard frame-by-frame sheet, and each frame is 37 x 45 pixels in size. // The final parameter (18) is the number of frames there are. You can omit this if your frames fill the entire sheet. game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18); - game.load.start(); } var mummy; function create() { diff --git a/Tests/sprites/animation 1.ts b/Tests/sprites/animation 1.ts index c2f3eaab..0550f861 100644 --- a/Tests/sprites/animation 1.ts +++ b/Tests/sprites/animation 1.ts @@ -2,16 +2,16 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder // The sprite sheet is a standard frame-by-frame sheet, and each frame is 37 x 45 pixels in size. // The final parameter (18) is the number of frames there are. You can omit this if your frames fill the entire sheet. game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18); - game.load.start(); + } diff --git a/Tests/sprites/animation 2.js b/Tests/sprites/animation 2.js index abb16cd1..efb1a109 100644 --- a/Tests/sprites/animation 2.js +++ b/Tests/sprites/animation 2.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.spritesheet('monster', 'assets/sprites/metalslug_monster39x40.png', 39, 40); - game.load.start(); } var monster; function create() { diff --git a/Tests/sprites/animation 2.ts b/Tests/sprites/animation 2.ts index ae9ff95f..a0ee3b1a 100644 --- a/Tests/sprites/animation 2.ts +++ b/Tests/sprites/animation 2.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.spritesheet('monster', 'assets/sprites/metalslug_monster39x40.png', 39, 40); - game.load.start(); + } diff --git a/Tests/sprites/create sprite 1.js b/Tests/sprites/create sprite 1.js index dcd1e6e4..85b1c167 100644 --- a/Tests/sprites/create sprite 1.js +++ b/Tests/sprites/create sprite 1.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('bunny', 'assets/sprites/bunny.png'); - game.load.start(); } function create() { // This will create a Sprite positioned at the top-left of the game (0,0) diff --git a/Tests/sprites/create sprite 1.ts b/Tests/sprites/create sprite 1.ts index 73247bc9..bc9a2fbd 100644 --- a/Tests/sprites/create sprite 1.ts +++ b/Tests/sprites/create sprite 1.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('bunny', 'assets/sprites/bunny.png'); - game.load.start(); + } diff --git a/Tests/sprites/origin 5.js b/Tests/sprites/origin 5.js index e260ca76..b11ed064 100644 --- a/Tests/sprites/origin 5.js +++ b/Tests/sprites/origin 5.js @@ -1,14 +1,13 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('disk', 'assets/sprites/oz_pov_melting_disk.png'); game.load.image('fuji', 'assets/tests/200x100corners.png'); game.load.image('fuji2', 'assets/tests/200x100corners2.png'); game.load.image('fuji3', 'assets/tests/320x200.png'); game.load.image('fuji4', 'assets/tests/320x200g.png'); - game.load.start(); } var fuji; var fuji2; diff --git a/Tests/sprites/origin 5.ts b/Tests/sprites/origin 5.ts index 3efd276b..0c9784f0 100644 --- a/Tests/sprites/origin 5.ts +++ b/Tests/sprites/origin 5.ts @@ -2,9 +2,9 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('disk', 'assets/sprites/oz_pov_melting_disk.png'); @@ -12,7 +12,7 @@ game.load.image('fuji2', 'assets/tests/200x100corners2.png'); game.load.image('fuji3', 'assets/tests/320x200.png'); game.load.image('fuji4', 'assets/tests/320x200g.png'); - game.load.start(); + } diff --git a/Tests/sprites/out of screen.ts b/Tests/sprites/out of screen.ts index 5d0513f4..3e9a052b 100644 --- a/Tests/sprites/out of screen.ts +++ b/Tests/sprites/out of screen.ts @@ -1,9 +1,9 @@ (function() { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.load.spritesheet('rect', 'assets/buttons/number-buttons-90x90.png', 90, 90); - game.load.start(); + } function create() { var rect: Phaser.Sprite, diff --git a/Tests/sprites/rotate around.ts b/Tests/sprites/rotate around.ts index 4ac66e55..db47fdad 100644 --- a/Tests/sprites/rotate around.ts +++ b/Tests/sprites/rotate around.ts @@ -1,12 +1,12 @@ (function() { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); var rotationSrv: Phaser.Point, angle: Number = 0; - function init() { + function preload() { game.load.spritesheet('x', 'assets/sprites/x.png', 220, 160); - game.load.start(); + } function create() { // Create 6 sprites rotating around the center at the beginning. diff --git a/Tests/sprites/scale sprite 1.js b/Tests/sprites/scale sprite 1.js index 5cec160e..a7d5fd16 100644 --- a/Tests/sprites/scale sprite 1.js +++ b/Tests/sprites/scale sprite 1.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('bunny', 'assets/sprites/bunny.png'); - game.load.start(); } var smallBunny; function create() { diff --git a/Tests/sprites/scale sprite 1.ts b/Tests/sprites/scale sprite 1.ts index 3c182607..9dfd18cf 100644 --- a/Tests/sprites/scale sprite 1.ts +++ b/Tests/sprites/scale sprite 1.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('bunny', 'assets/sprites/bunny.png'); - game.load.start(); + } diff --git a/Tests/sprites/scale sprite 2.js b/Tests/sprites/scale sprite 2.js index 9bbece0b..9135ec07 100644 --- a/Tests/sprites/scale sprite 2.js +++ b/Tests/sprites/scale sprite 2.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('bunny', 'assets/sprites/bunny.png'); - game.load.start(); } var bigBunny; function create() { diff --git a/Tests/sprites/scale sprite 2.ts b/Tests/sprites/scale sprite 2.ts index 1f2868e5..baa69df9 100644 --- a/Tests/sprites/scale sprite 2.ts +++ b/Tests/sprites/scale sprite 2.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('bunny', 'assets/sprites/bunny.png'); - game.load.start(); + } diff --git a/Tests/sprites/scale sprite 3.js b/Tests/sprites/scale sprite 3.js index 4c14ba20..a6bb903c 100644 --- a/Tests/sprites/scale sprite 3.js +++ b/Tests/sprites/scale sprite 3.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('bunny', 'assets/sprites/bunny.png'); - game.load.start(); } var bunny; function create() { diff --git a/Tests/sprites/scale sprite 3.ts b/Tests/sprites/scale sprite 3.ts index 487a2f39..82cb3a5a 100644 --- a/Tests/sprites/scale sprite 3.ts +++ b/Tests/sprites/scale sprite 3.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('bunny', 'assets/sprites/bunny.png'); - game.load.start(); + } diff --git a/Tests/sprites/scale sprite 4.js b/Tests/sprites/scale sprite 4.js index aae903f6..7e6d98ac 100644 --- a/Tests/sprites/scale sprite 4.js +++ b/Tests/sprites/scale sprite 4.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('bunny', 'assets/sprites/bunny.png'); - game.load.start(); } var bunny; var tweenUp; diff --git a/Tests/sprites/scale sprite 4.ts b/Tests/sprites/scale sprite 4.ts index 193640b1..bc11458d 100644 --- a/Tests/sprites/scale sprite 4.ts +++ b/Tests/sprites/scale sprite 4.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('bunny', 'assets/sprites/bunny.png'); - game.load.start(); + } diff --git a/Tests/sprites/scale sprite 5.js b/Tests/sprites/scale sprite 5.js index 2447c9ae..0735e97f 100644 --- a/Tests/sprites/scale sprite 5.js +++ b/Tests/sprites/scale sprite 5.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('fuji', 'assets/pics/atari_fujilogo.png'); - game.load.start(); } var fuji; var tween; diff --git a/Tests/sprites/scale sprite 5.ts b/Tests/sprites/scale sprite 5.ts index aa180503..d8cfc22c 100644 --- a/Tests/sprites/scale sprite 5.ts +++ b/Tests/sprites/scale sprite 5.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('fuji', 'assets/pics/atari_fujilogo.png'); - game.load.start(); + } diff --git a/Tests/sprites/sprite origin 1.js b/Tests/sprites/sprite origin 1.js index 4bf0dbba..027133e7 100644 --- a/Tests/sprites/sprite origin 1.js +++ b/Tests/sprites/sprite origin 1.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('fuji', 'assets/pics/atari_fujilogo.png'); - game.load.start(); } var fuji; function create() { diff --git a/Tests/sprites/sprite origin 1.ts b/Tests/sprites/sprite origin 1.ts index 9b27c0f0..ee19522d 100644 --- a/Tests/sprites/sprite origin 1.ts +++ b/Tests/sprites/sprite origin 1.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('fuji', 'assets/pics/atari_fujilogo.png'); - game.load.start(); + } diff --git a/Tests/sprites/sprite origin 2.js b/Tests/sprites/sprite origin 2.js index d7443315..5c700a30 100644 --- a/Tests/sprites/sprite origin 2.js +++ b/Tests/sprites/sprite origin 2.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('fuji', 'assets/pics/atari_fujilogo.png'); - game.load.start(); } var fuji; function create() { diff --git a/Tests/sprites/sprite origin 2.ts b/Tests/sprites/sprite origin 2.ts index 4453e1d0..382b04f1 100644 --- a/Tests/sprites/sprite origin 2.ts +++ b/Tests/sprites/sprite origin 2.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('fuji', 'assets/pics/atari_fujilogo.png'); - game.load.start(); + } diff --git a/Tests/sprites/sprite origin 3.js b/Tests/sprites/sprite origin 3.js index 4c2a515a..8ac9181d 100644 --- a/Tests/sprites/sprite origin 3.js +++ b/Tests/sprites/sprite origin 3.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('fuji', 'assets/pics/atari_fujilogo.png'); - game.load.start(); } var fuji; var tween; diff --git a/Tests/sprites/sprite origin 3.ts b/Tests/sprites/sprite origin 3.ts index c4302397..9ca16b55 100644 --- a/Tests/sprites/sprite origin 3.ts +++ b/Tests/sprites/sprite origin 3.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('fuji', 'assets/pics/atari_fujilogo.png'); - game.load.start(); + } diff --git a/Tests/sprites/sprite origin 4.js b/Tests/sprites/sprite origin 4.js index 73368191..8cd87503 100644 --- a/Tests/sprites/sprite origin 4.js +++ b/Tests/sprites/sprite origin 4.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('fuji', 'assets/pics/atari_fujilogo.png'); - game.load.start(); } var fuji; var tweenUp; diff --git a/Tests/sprites/sprite origin 4.ts b/Tests/sprites/sprite origin 4.ts index 6fb43bf6..7b644dbd 100644 --- a/Tests/sprites/sprite origin 4.ts +++ b/Tests/sprites/sprite origin 4.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('fuji', 'assets/pics/atari_fujilogo.png'); - game.load.start(); + } diff --git a/Tests/stage/blur filter.js b/Tests/stage/blur filter.js index 0fe9b70d..b1916385 100644 --- a/Tests/stage/blur filter.js +++ b/Tests/stage/blur filter.js @@ -1,9 +1,8 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); - game.load.start(); } function create() { game.world.setSize(1920, 1200); diff --git a/Tests/stage/blur filter.ts b/Tests/stage/blur filter.ts index 6a478d5c..3f0c3804 100644 --- a/Tests/stage/blur filter.ts +++ b/Tests/stage/blur filter.ts @@ -2,12 +2,12 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); - game.load.start(); + } diff --git a/Tests/stage/brightness filter.js b/Tests/stage/brightness filter.js index 6ff93d45..02dc7ee5 100644 --- a/Tests/stage/brightness filter.js +++ b/Tests/stage/brightness filter.js @@ -1,9 +1,8 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); - game.load.start(); } function create() { game.world.setSize(1920, 1200); diff --git a/Tests/stage/brightness filter.ts b/Tests/stage/brightness filter.ts index 7b8f100b..ba94f875 100644 --- a/Tests/stage/brightness filter.ts +++ b/Tests/stage/brightness filter.ts @@ -2,12 +2,12 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); - game.load.start(); + } diff --git a/Tests/stage/contrast filter.js b/Tests/stage/contrast filter.js index 11b2fb22..0f2b3c94 100644 --- a/Tests/stage/contrast filter.js +++ b/Tests/stage/contrast filter.js @@ -1,9 +1,8 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); - game.load.start(); } function create() { game.world.setSize(1920, 1200); diff --git a/Tests/stage/contrast filter.ts b/Tests/stage/contrast filter.ts index 43e55ec1..ac2d5e27 100644 --- a/Tests/stage/contrast filter.ts +++ b/Tests/stage/contrast filter.ts @@ -2,12 +2,12 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); - game.load.start(); + } diff --git a/Tests/stage/grayscale filter.js b/Tests/stage/grayscale filter.js index 0e6ed430..89cfb2d1 100644 --- a/Tests/stage/grayscale filter.js +++ b/Tests/stage/grayscale filter.js @@ -1,9 +1,8 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); - game.load.start(); } function create() { game.world.setSize(1920, 1200); diff --git a/Tests/stage/grayscale filter.ts b/Tests/stage/grayscale filter.ts index 2baeb0cd..cc0de18a 100644 --- a/Tests/stage/grayscale filter.ts +++ b/Tests/stage/grayscale filter.ts @@ -2,12 +2,12 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); - game.load.start(); + } diff --git a/Tests/stage/hue rotate filter.js b/Tests/stage/hue rotate filter.js index e1684de0..6cebd1ce 100644 --- a/Tests/stage/hue rotate filter.js +++ b/Tests/stage/hue rotate filter.js @@ -1,11 +1,10 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.image('backdrop', 'assets/pics/large-color-wheel.png'); game.load.image('coke', 'assets/sprites/cokecan.png'); game.load.image('mushroom', 'assets/sprites/mushroom2.png'); - game.load.start(); } var hue = 0; function create() { diff --git a/Tests/stage/hue rotate filter.ts b/Tests/stage/hue rotate filter.ts index 362c11b2..d7fbc122 100644 --- a/Tests/stage/hue rotate filter.ts +++ b/Tests/stage/hue rotate filter.ts @@ -2,14 +2,14 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.image('backdrop', 'assets/pics/large-color-wheel.png'); game.load.image('coke', 'assets/sprites/cokecan.png'); game.load.image('mushroom', 'assets/sprites/mushroom2.png'); - game.load.start(); + } diff --git a/Tests/stage/sepia filter.js b/Tests/stage/sepia filter.js index 6302640f..39a21e8c 100644 --- a/Tests/stage/sepia filter.js +++ b/Tests/stage/sepia filter.js @@ -1,9 +1,8 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); - game.load.start(); } function create() { game.world.setSize(1920, 1200); diff --git a/Tests/stage/sepia filter.ts b/Tests/stage/sepia filter.ts index e6fb78a8..78ca285c 100644 --- a/Tests/stage/sepia filter.ts +++ b/Tests/stage/sepia filter.ts @@ -2,12 +2,12 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); - game.load.start(); + } diff --git a/Tests/textures/dynamic texture 1.js b/Tests/textures/dynamic texture 1.js index 620a7c38..ab8ba296 100644 --- a/Tests/textures/dynamic texture 1.js +++ b/Tests/textures/dynamic texture 1.js @@ -1,9 +1,8 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.image('ball', 'assets/sprites/shinyball.png'); - game.load.start(); } var wobblyBall; function create() { diff --git a/Tests/textures/dynamic texture 1.ts b/Tests/textures/dynamic texture 1.ts index c5b0ee40..d2dc41bf 100644 --- a/Tests/textures/dynamic texture 1.ts +++ b/Tests/textures/dynamic texture 1.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.image('ball', 'assets/sprites/shinyball.png'); - game.load.start(); + } diff --git a/Tests/textures/filter test.js b/Tests/textures/filter test.js index 4e670bbc..961e9f29 100644 --- a/Tests/textures/filter test.js +++ b/Tests/textures/filter test.js @@ -1,11 +1,10 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); + function preload() { game.load.image('backdrop', 'assets/pics/large-color-wheel.png'); game.load.image('coke', 'assets/sprites/cokecan.png'); game.load.image('mushroom', 'assets/sprites/mushroom2.png'); - game.load.start(); } var hue = 0; var texture; diff --git a/Tests/textures/filter test.ts b/Tests/textures/filter test.ts index ab1dcdee..f2d69b7a 100644 --- a/Tests/textures/filter test.ts +++ b/Tests/textures/filter test.ts @@ -2,14 +2,14 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render); - function init() { + function preload() { game.load.image('backdrop', 'assets/pics/large-color-wheel.png'); game.load.image('coke', 'assets/sprites/cokecan.png'); game.load.image('mushroom', 'assets/sprites/mushroom2.png'); - game.load.start(); + } diff --git a/Tests/textures/starling texture atlas.js b/Tests/textures/starling texture atlas.js index 93710951..1a05be32 100644 --- a/Tests/textures/starling texture atlas.js +++ b/Tests/textures/starling texture atlas.js @@ -1,13 +1,12 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { // Starling/Sparrow XML Texture Atlas Method 1 // // In this example we assume that the XML data is stored in an external file game.load.atlas('bits', 'assets/sprites/shoebox.png', 'assets/sprites/shoebox.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); game.load.atlas('bot', 'assets/sprites/shoebot.png', 'assets/sprites/shoebot.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); - game.load.start(); } var bits; var bot; diff --git a/Tests/textures/starling texture atlas.ts b/Tests/textures/starling texture atlas.ts index 3a211713..1942520d 100644 --- a/Tests/textures/starling texture atlas.ts +++ b/Tests/textures/starling texture atlas.ts @@ -2,9 +2,9 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { // Starling/Sparrow XML Texture Atlas Method 1 // @@ -12,7 +12,7 @@ game.load.atlas('bits', 'assets/sprites/shoebox.png', 'assets/sprites/shoebox.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); game.load.atlas('bot', 'assets/sprites/shoebot.png', 'assets/sprites/shoebot.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING); - game.load.start(); + } diff --git a/Tests/textures/texture atlas 1.js b/Tests/textures/texture atlas 1.js index ae99cc46..9f47abc4 100644 --- a/Tests/textures/texture atlas 1.js +++ b/Tests/textures/texture atlas 1.js @@ -1,13 +1,12 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Texture Atlas Method 1 // // In this example we assume that the TexturePacker JSON data is a string of json data stored as a var // (in this case botData) game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData); - game.load.start(); } var bot; function create() { diff --git a/Tests/textures/texture atlas 1.ts b/Tests/textures/texture atlas 1.ts index 839a1f22..49022ab7 100644 --- a/Tests/textures/texture atlas 1.ts +++ b/Tests/textures/texture atlas 1.ts @@ -2,9 +2,9 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Texture Atlas Method 1 // @@ -12,7 +12,7 @@ // (in this case botData) game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData); - game.load.start(); + } diff --git a/Tests/textures/texture atlas 2.js b/Tests/textures/texture atlas 2.js index bc9d2b70..58f4c1fb 100644 --- a/Tests/textures/texture atlas 2.js +++ b/Tests/textures/texture atlas 2.js @@ -1,13 +1,12 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { // Texture Atlas Method 2 // // In this example we assume that the TexturePacker JSON data is a real json object stored as a var // (in this case botData) game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData); - game.load.start(); } var bot; function create() { diff --git a/Tests/textures/texture atlas 2.ts b/Tests/textures/texture atlas 2.ts index 44050693..c6de059b 100644 --- a/Tests/textures/texture atlas 2.ts +++ b/Tests/textures/texture atlas 2.ts @@ -2,9 +2,9 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { // Texture Atlas Method 2 // @@ -12,7 +12,7 @@ // (in this case botData) game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData); - game.load.start(); + } diff --git a/Tests/textures/texture atlas 3.js b/Tests/textures/texture atlas 3.js index 68f34d61..1242d778 100644 --- a/Tests/textures/texture atlas 3.js +++ b/Tests/textures/texture atlas 3.js @@ -1,12 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { // Texture Atlas Method 3 // // In this example we assume that the TexturePacker JSON data is stored in an external file game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json'); - game.load.start(); } var bot; function create() { diff --git a/Tests/textures/texture atlas 3.ts b/Tests/textures/texture atlas 3.ts index bcab4898..76a6af10 100644 --- a/Tests/textures/texture atlas 3.ts +++ b/Tests/textures/texture atlas 3.ts @@ -2,16 +2,16 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { // Texture Atlas Method 3 // // In this example we assume that the TexturePacker JSON data is stored in an external file game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json'); - game.load.start(); + } diff --git a/Tests/textures/texture atlas 4.js b/Tests/textures/texture atlas 4.js index 6db30e4a..20653eac 100644 --- a/Tests/textures/texture atlas 4.js +++ b/Tests/textures/texture atlas 4.js @@ -1,12 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Texture Atlas Method 4 // // We load a TexturePacker JSON file and image and show you how to make several unique sprites from the same file game.load.atlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json'); - game.load.start(); } var chick; var car; diff --git a/Tests/textures/texture atlas 4.ts b/Tests/textures/texture atlas 4.ts index 7eb3b98c..3673427a 100644 --- a/Tests/textures/texture atlas 4.ts +++ b/Tests/textures/texture atlas 4.ts @@ -2,16 +2,16 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Texture Atlas Method 4 // // We load a TexturePacker JSON file and image and show you how to make several unique sprites from the same file game.load.atlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json'); - game.load.start(); + } diff --git a/Tests/tilemaps/csv tilemap.js b/Tests/tilemaps/csv tilemap.js index 018d2418..8e659c6c 100644 --- a/Tests/tilemaps/csv tilemap.js +++ b/Tests/tilemaps/csv tilemap.js @@ -1,14 +1,13 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { // CSV Tilemap Test // First we load our map data (a csv file) game.load.text('csvtest', 'assets/maps/catastrophi_level2.csv'); // Then we load the actual tile sheet image game.load.image('csvtiles', 'assets/tiles/catastrophi_tiles_16.png'); - game.load.start(); } function create() { // This creates the tilemap using the csv and tile sheet we loaded. diff --git a/Tests/tilemaps/csv tilemap.ts b/Tests/tilemaps/csv tilemap.ts index 35d113f1..ce992bd5 100644 --- a/Tests/tilemaps/csv tilemap.ts +++ b/Tests/tilemaps/csv tilemap.ts @@ -3,9 +3,9 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { // CSV Tilemap Test @@ -15,7 +15,7 @@ // Then we load the actual tile sheet image game.load.image('csvtiles', 'assets/tiles/catastrophi_tiles_16.png'); - game.load.start(); + } diff --git a/Tests/tilemaps/map draw.js b/Tests/tilemaps/map draw.js index bd875f4d..9fb9dba1 100644 --- a/Tests/tilemaps/map draw.js +++ b/Tests/tilemaps/map draw.js @@ -1,12 +1,11 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { game.load.text('platform', 'assets/maps/mapdraw.json'); game.load.image('tiles', 'assets/tiles/platformer_tiles.png'); game.load.image('carrot', 'assets/sprites/carrot.png'); - game.load.start(); } var map; var emitter; diff --git a/Tests/tilemaps/map draw.ts b/Tests/tilemaps/map draw.ts index b72bf218..a6710746 100644 --- a/Tests/tilemaps/map draw.ts +++ b/Tests/tilemaps/map draw.ts @@ -3,15 +3,15 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { game.load.text('platform', 'assets/maps/mapdraw.json'); game.load.image('tiles', 'assets/tiles/platformer_tiles.png'); game.load.image('carrot', 'assets/sprites/carrot.png'); - game.load.start(); + } diff --git a/Tests/tilemaps/tiled layers.js b/Tests/tilemaps/tiled layers.js index e1ce1462..6d72c56c 100644 --- a/Tests/tilemaps/tiled layers.js +++ b/Tests/tilemaps/tiled layers.js @@ -1,15 +1,14 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { // Tiled Tilemap Test // First we load our map data (a json file exported from the map editor Tiled) // This data file has several layers within it. Phaser will render them all. game.load.text('jsontest', 'assets/maps/multi-layer-test.json'); // Then we load the actual tile sheet image game.load.image('jsontiles', 'assets/tiles/platformer_tiles.png'); - game.load.start(); } var map; function create() { diff --git a/Tests/tilemaps/tiled layers.ts b/Tests/tilemaps/tiled layers.ts index 2b67f4d4..4636c51b 100644 --- a/Tests/tilemaps/tiled layers.ts +++ b/Tests/tilemaps/tiled layers.ts @@ -3,9 +3,9 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { // Tiled Tilemap Test @@ -16,7 +16,7 @@ // Then we load the actual tile sheet image game.load.image('jsontiles', 'assets/tiles/platformer_tiles.png'); - game.load.start(); + } diff --git a/Tests/tilemaps/tiled tilemap.js b/Tests/tilemaps/tiled tilemap.js index 0ace4b10..876ab223 100644 --- a/Tests/tilemaps/tiled tilemap.js +++ b/Tests/tilemaps/tiled tilemap.js @@ -1,15 +1,14 @@ /// /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); + function preload() { // Tiled Tilemap Test // First we load our map data (a json file exported from the map editor Tiled) game.load.text('jsontest', 'assets/maps/test.json'); //myGame.loader.addTextFile('jsontest', 'assets/maps/multi-layer-test.json'); // Then we load the actual tile sheet image game.load.image('jsontiles', 'assets/tiles/platformer_tiles.png'); - game.load.start(); } function create() { // This creates the tilemap using the json data and tile sheet we loaded. diff --git a/Tests/tilemaps/tiled tilemap.ts b/Tests/tilemaps/tiled tilemap.ts index 8beb8e86..c355c950 100644 --- a/Tests/tilemaps/tiled tilemap.ts +++ b/Tests/tilemaps/tiled tilemap.ts @@ -3,9 +3,9 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update); - function init() { + function preload() { // Tiled Tilemap Test @@ -16,7 +16,7 @@ // Then we load the actual tile sheet image game.load.image('jsontiles', 'assets/tiles/platformer_tiles.png'); - game.load.start(); + } diff --git a/Tests/tweens/bounce.js b/Tests/tweens/bounce.js index 61f010d9..f60c87bc 100644 --- a/Tests/tweens/bounce.js +++ b/Tests/tweens/bounce.js @@ -1,9 +1,8 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { game.load.image('atari', 'assets/sprites/atari130xe.png'); - game.load.start(); } var atari; function create() { diff --git a/Tests/tweens/bounce.ts b/Tests/tweens/bounce.ts index 067bdaab..c4b67471 100644 --- a/Tests/tweens/bounce.ts +++ b/Tests/tweens/bounce.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.image('atari', 'assets/sprites/atari130xe.png'); - game.load.start(); + } diff --git a/Tests/tweens/easing example 1.ts b/Tests/tweens/easing example 1.ts index 49900931..6431ddeb 100644 --- a/Tests/tweens/easing example 1.ts +++ b/Tests/tweens/easing example 1.ts @@ -2,12 +2,12 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.spritesheet('shadow', 'assets/tests/tween/shadow.png', 80, 15); game.load.spritesheet('PHASER', 'assets/tests/tween/PHASER.png', 70, 90); - game.load.start(); + } function create() { diff --git a/Tests/tweens/easing example 2.ts b/Tests/tweens/easing example 2.ts index 97c57001..f5c0f280 100644 --- a/Tests/tweens/easing example 2.ts +++ b/Tests/tweens/easing example 2.ts @@ -1,11 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.spritesheet('shadow', 'assets/tests/tween/shadow.png', 80, 15); game.load.spritesheet('PHASER', 'assets/tests/tween/PHASER.png', 70, 90); - game.load.start(); + } function create() { var item: Phaser.Sprite; diff --git a/Tests/tweens/easing example 3.ts b/Tests/tweens/easing example 3.ts index 095e17a8..d3639bd8 100644 --- a/Tests/tweens/easing example 3.ts +++ b/Tests/tweens/easing example 3.ts @@ -1,11 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.spritesheet('shadow', 'assets/tests/tween/shadow.png', 80, 15); game.load.spritesheet('PHASER', 'assets/tests/tween/PHASER.png', 70, 90); - game.load.start(); + } function create() { var item: Phaser.Sprite, diff --git a/Tests/tweens/easing example 4.ts b/Tests/tweens/easing example 4.ts index 0e0cd378..2b808918 100644 --- a/Tests/tweens/easing example 4.ts +++ b/Tests/tweens/easing example 4.ts @@ -1,11 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.spritesheet('shadow', 'assets/tests/tween/shadow.png', 80, 15); game.load.spritesheet('PHASER', 'assets/tests/tween/PHASER.png', 70, 90); - game.load.start(); + } function create() { var item: Phaser.Sprite, diff --git a/Tests/tweens/easing example 5.ts b/Tests/tweens/easing example 5.ts index 88166ce8..7ed7fee6 100644 --- a/Tests/tweens/easing example 5.ts +++ b/Tests/tweens/easing example 5.ts @@ -1,11 +1,11 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.spritesheet('shadow', 'assets/tests/tween/shadow.png', 138, 15); game.load.spritesheet('PHASER', 'assets/tests/tween/PHASER.png', 70, 90); - game.load.start(); + } function create() { var item: Phaser.Sprite, diff --git a/Tests/tweens/easing example 6.ts b/Tests/tweens/easing example 6.ts index a220d7c6..a6bbf060 100644 --- a/Tests/tweens/easing example 6.ts +++ b/Tests/tweens/easing example 6.ts @@ -1,12 +1,12 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { game.load.spritesheet('shadow', 'assets/tests/tween/shadow.png', 80, 15); game.load.spritesheet('PHASER', 'assets/tests/tween/PHASER.png', 70, 90); game.load.spritesheet('ribbon', 'assets/tests/tween/ribbon.png', 731, 49); - game.load.start(); + } function create() { var ribbon: Phaser.Sprite = game.add.sprite(-1000, 256, 'ribbon'); diff --git a/Tests/tweens/tween loop 1.js b/Tests/tweens/tween loop 1.js index d677e689..080e994e 100644 --- a/Tests/tweens/tween loop 1.js +++ b/Tests/tweens/tween loop 1.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('swirl', 'assets/pics/color_wheel_swirl.png'); - game.load.start(); } var swirl; function create() { diff --git a/Tests/tweens/tween loop 1.ts b/Tests/tweens/tween loop 1.ts index a5ad8638..5330ee14 100644 --- a/Tests/tweens/tween loop 1.ts +++ b/Tests/tweens/tween loop 1.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('swirl', 'assets/pics/color_wheel_swirl.png'); - game.load.start(); + } diff --git a/Tests/tweens/tween loop 2.js b/Tests/tweens/tween loop 2.js index dd7ad6a2..c98d5e24 100644 --- a/Tests/tweens/tween loop 2.js +++ b/Tests/tweens/tween loop 2.js @@ -1,10 +1,9 @@ /// (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); - function init() { + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('swirl', 'assets/pics/color_wheel_swirl.png'); - game.load.start(); } var swirl; function create() { diff --git a/Tests/tweens/tween loop 2.ts b/Tests/tweens/tween loop 2.ts index 59501193..0c0ac696 100644 --- a/Tests/tweens/tween loop 2.ts +++ b/Tests/tweens/tween loop 2.ts @@ -2,13 +2,13 @@ (function () { - var game = new Phaser.Game(this, 'game', 800, 600, init, create); + var game = new Phaser.Game(this, 'game', 800, 600, preload, create); - function init() { + function preload() { // Using Phasers asset loader we load up a PNG from the assets folder game.load.image('swirl', 'assets/pics/color_wheel_swirl.png'); - game.load.start(); + } diff --git a/build/phaser.d.ts b/build/phaser.d.ts index decd809b..c8998000 100644 --- a/build/phaser.d.ts +++ b/build/phaser.d.ts @@ -3829,15 +3829,14 @@ module Phaser { * Loader constructor * * @param game {Phaser.Game} Current game instance. - * @param callback {function} This will be called when assets completely loaded. */ - constructor(game: Game, callback); + constructor(game: Game); /** - * Local private reference to game. + * Local reference to Game. */ - private _game; + public game: Game; /** - * Array stors assets keys. So you can get that asset by its unique key. + * Array stores assets keys. So you can get that asset by its unique key. */ private _keys; /** @@ -3845,12 +3844,6 @@ module Phaser { */ private _fileList; /** - * Game initialial assets loading callback. - */ - private _gameCreateComplete; - private _onComplete; - private _onFileLoad; - /** * Indicates assets loading progress. (from 0 to 100) * @type {number} */ @@ -3862,6 +3855,11 @@ module Phaser { */ private _queueSize; /** + * True if the Loader is in the process of loading a queue. + * @type {boolean} + */ + public isLoading: bool; + /** * True if game is completely loaded. * @type {boolean} */ @@ -3876,6 +3874,10 @@ module Phaser { * @type {string} */ public crossOrigin: string; + public onFileComplete: Signal; + public onFileError: Signal; + public onLoadStart: Signal; + public onLoadComplete: Signal; /** * TextureAtlas data format constants */ @@ -3935,10 +3937,8 @@ module Phaser { public removeAll(): void; /** * Load assets. - * @param onFileLoadCallback {function} Called when each file loaded successfully. - * @param onCompleteCallback {function} Called when all assets completely loaded. */ - public start(onFileLoadCallback?, onCompleteCallback?): void; + public start(): void; /** * Load files. Private method ONLY used by loader. */ @@ -4029,9 +4029,9 @@ module Phaser { */ constructor(game: Game); /** - * Local private reference to game. + * Local reference to Game. */ - private _game; + public game: Game; /** * Canvas key-value container. * @type {object} @@ -5105,9 +5105,9 @@ module Phaser { */ constructor(game: Game, x: number, y: number, width: number, height: number); /** - * Local private reference to Game. + * Local reference to Game. */ - private _game; + public game: Game; /** * Local container for storing cameras. */ @@ -5334,9 +5334,9 @@ module Phaser { */ constructor(object, game: Game); /** - * Local private reference to game. + * Local reference to Game. */ - private _game; + public game: Game; /** * Manager of this tween. * @type {Phaser.TweenManager} @@ -5880,7 +5880,7 @@ module Phaser { private _tempTileBlock; private _tempBlockResults; /** - * Local private reference to game. + * Local reference to Game. */ public game: Game; /** @@ -6098,9 +6098,9 @@ module Phaser { */ constructor(game: Game, tilemap: Tilemap, index: number, width: number, height: number); /** - * Local private reference to game. + * Local reference to Game. */ - private _game; + public game: Game; /** * You can give this Tile a friendly name to help with debugging. Never used internally. * @type {string} @@ -6430,9 +6430,9 @@ module Phaser { */ constructor(game: Game); /** - * Local private reference to Game + * Local reference to Game */ - private _game; + public game: Game; /** * Local private reference to World */ @@ -6872,9 +6872,9 @@ module Phaser { */ constructor(game: Game, width: number, height: number); /** - * Local private reference to game. + * Local reference to Game. */ - private _game; + public game: Game; /** * Stage height when start the game. * @type {number} @@ -7036,9 +7036,9 @@ module Phaser { */ constructor(game: Game); /** - * Local private reference to game. + * Local reference to Game. */ - private _game; + public game: Game; /** * Engine logo. */ @@ -7090,9 +7090,9 @@ module Phaser { */ constructor(game: Game, width: number, height: number); /** - * Local private reference to game. + * Local reference to Game. */ - private _game; + public game: Game; /** * Canvas element used by engine. * @type {HTMLCanvasElement} @@ -7201,9 +7201,9 @@ module Phaser { */ constructor(game: Game, parent: string, width: number, height: number); /** - * Local private reference to game. + * Local reference to Game. */ - private _game; + public game: Game; /** * Background color of the stage (defaults to black). Set via the public backgroundColor property. * @type {string} @@ -7288,12 +7288,6 @@ module Phaser { */ public disableVisibilityChange: bool; /** - * An optional 'fix' for the horrendous Android stock browser bug - * https://code.google.com/p/android/issues/detail?id=39247 - * @type {boolean} - */ - public patchAndroidClearRectBug: bool; - /** * Stage boot */ public boot(): void; @@ -7486,9 +7480,9 @@ module Phaser { */ constructor(game: Game); /** - * Local private reference to Game + * Local reference to Game */ - private _game; + public game: Game; /** * Local private array which is the container of all tween objects. */ @@ -7576,9 +7570,9 @@ module Phaser { */ constructor(game: Game, width: number, height: number); /** - * Local private reference to game. + * Local reference to Game. */ - private _game; + public game: Game; /** * Camera manager of this world. * @type {CameraManager} @@ -7656,6 +7650,12 @@ module Phaser { */ constructor(); /** + * An optional 'fix' for the horrendous Android stock browser bug + * https://code.google.com/p/android/issues/detail?id=39247 + * @type {boolean} + */ + public patchAndroidClearRectBug: bool; + /** * Is running desktop? * @type {boolean} */ @@ -7899,9 +7899,9 @@ module Phaser { */ constructor(game: Game, callback); /** - * Local private reference to game. + * Local reference to Game. */ - private _game; + public game: Game; /** * The function to be called each frame. Will be called in the context of _game * @property callback @@ -8105,7 +8105,7 @@ module Phaser { private _highestRenderObject; private _highestInputPriorityID; /** - * Local private reference to game. + * Local reference to Game. * @property game * @type {Phaser.Game} * @private @@ -8444,12 +8444,12 @@ module Phaser { */ constructor(game: Game); /** - * Local private reference to game. + * Local reference to Game. * @property _game * @type {Game} * @private **/ - private _game; + public game: Game; private _p1; private _p2; private _p3; @@ -8812,6 +8812,13 @@ module Phaser { */ public game: Game; /** + * How often should the input pointers be checked for updates? + * A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on. + * @type {number} + */ + public pollRate: number; + private _pollCounter; + /** * A 1x1 sized canvas used for pixel-perfect checks * @type {HTMLCanvasElement} */ @@ -9117,6 +9124,7 @@ module Phaser { * @method removeGameObject **/ public removeGameObject(index: number): void; + public pollLocked : bool; /** * Updates the Input Manager. Called by the core Game loop. * @method update @@ -9507,24 +9515,19 @@ module Phaser { * @param parent {string} ID of its parent DOM element. * @param width {number} The width of your game in game pixels. * @param height {number} The height of your game in game pixels. - * @param initCallback {function} Init callback invoked when init default screen. + * @param preloadCallback {function} Preload callback invoked when init default screen. * @param createCallback {function} Create callback invoked when create default screen. * @param updateCallback {function} Update callback invoked when update default screen. * @param renderCallback {function} Render callback invoked when render default screen. * @param destroyCallback {function} Destroy callback invoked when state is destroyed. */ - constructor(callbackContext, parent?: string, width?: number, height?: number, initCallback?, createCallback?, updateCallback?, renderCallback?, destroyCallback?); + constructor(callbackContext, parent?: string, width?: number, height?: number, preloadCallback?, createCallback?, updateCallback?, renderCallback?, destroyCallback?); public id: number; /** * Game loop trigger wrapper. */ public _raf: RequestAnimationFrame; /** - * Milliseconds of time per step of the game loop. - * @type {number} - */ - private _step; - /** * Whether load complete loading or not. * @type {boolean} */ @@ -9557,7 +9560,7 @@ module Phaser { * This will be called when init states. (loading assets...) * @type {function} */ - public onInitCallback; + public onPreloadCallback; /** * This will be called when create states. (setup states...) * @type {function} @@ -9692,7 +9695,7 @@ module Phaser { private boot(parent, width, height); public setRenderer(type: number): void; /** - * Called when the load has finished after init was run. + * Called when the load has finished after preload was run. */ private loadComplete(); /** @@ -9714,13 +9717,13 @@ module Phaser { private startState(); /** * Set the most common state callbacks (init, create, update, render). - * @param initCallback {function} Init callback invoked when init state. + * @param preloadCallback {function} Init callback invoked when init state. * @param createCallback {function} Create callback invoked when create state. * @param updateCallback {function} Update callback invoked when update state. * @param renderCallback {function} Render callback invoked when render state. * @param destroyCallback {function} Destroy callback invoked when state is destroyed. */ - public setCallbacks(initCallback?, createCallback?, updateCallback?, renderCallback?, destroyCallback?): void; + public setCallbacks(preloadCallback?, createCallback?, updateCallback?, renderCallback?, destroyCallback?): void; /** * Switch to a new State. * @param state {State} The state you want to switch to. @@ -9756,9 +9759,9 @@ module Phaser { */ constructor(game: Game, parent: Sprite, frameData: FrameData, name: string, frames, delay: number, looped: bool); /** - * Local private reference to game. + * Local reference to Game. */ - private _game; + public game: Game; /** * Local private reference to its owner sprite. * @type {Sprite} diff --git a/build/phaser.js b/build/phaser.js index c779dea5..05f74d9e 100644 --- a/build/phaser.js +++ b/build/phaser.js @@ -5204,7 +5204,7 @@ var Phaser; if (camera == null) { - camera = this._game.camera; + camera = this.game.camera; } var objectScreenPos: Point = objectOrGroup.getScreenXY(null, camera); @@ -5286,7 +5286,7 @@ var Phaser; point = new Phaser.Point(); } if(camera == null) { - camera = this._game.camera; + camera = this.game.camera; } point.x = sprite.x - camera.x * sprite.transform.scrollFactor.x; point.y = sprite.y - camera.y * sprite.transform.scrollFactor.y; @@ -5302,7 +5302,7 @@ var Phaser; /* static setBoundsFromWorld(action?: number = GameObject.OUT_OF_BOUNDS_STOP) { - this.setBounds(this._game.world.bounds.x, this._game.world.bounds.y, this._game.world.bounds.width, this._game.world.bounds.height); + this.setBounds(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height); this.outOfBoundsAction = action; } @@ -7396,21 +7396,24 @@ var Phaser; * Loader constructor * * @param game {Phaser.Game} Current game instance. - * @param callback {function} This will be called when assets completely loaded. */ - function Loader(game, callback) { + function Loader(game) { /** * The crossOrigin value applied to loaded images * @type {string} */ this.crossOrigin = ''; - this._game = game; - this._gameCreateComplete = callback; + this.game = game; this._keys = []; this._fileList = { }; this._xhr = new XMLHttpRequest(); this._queueSize = 0; + this.isLoading = false; + this.onFileComplete = new Phaser.Signal(); + this.onFileError = new Phaser.Signal(); + this.onLoadStart = new Phaser.Signal(); + this.onLoadComplete = new Phaser.Signal(); } Loader.TEXTURE_ATLAS_JSON_ARRAY = 0; Loader.TEXTURE_ATLAS_JSON_HASH = 1; @@ -7420,6 +7423,7 @@ var Phaser; */ function () { this._queueSize = 0; + this.isLoading = false; }; Object.defineProperty(Loader.prototype, "queueSize", { get: function () { @@ -7617,29 +7621,22 @@ var Phaser; }; Loader.prototype.start = /** * Load assets. - * @param onFileLoadCallback {function} Called when each file loaded successfully. - * @param onCompleteCallback {function} Called when all assets completely loaded. */ - function (onFileLoadCallback, onCompleteCallback) { - if (typeof onFileLoadCallback === "undefined") { onFileLoadCallback = null; } - if (typeof onCompleteCallback === "undefined") { onCompleteCallback = null; } + function () { + if(this.isLoading) { + return; + } this.progress = 0; this.hasLoaded = false; - this._onComplete = onCompleteCallback; - if(onCompleteCallback == null) { - this._onComplete = this._game.onCreateCallback; - } - this._onFileLoad = onFileLoadCallback; + this.isLoading = true; + this.onLoadStart.dispatch(this.queueSize); if(this._keys.length > 0) { this._progressChunk = 100 / this._keys.length; this.loadFile(); } else { this.progress = 100; this.hasLoaded = true; - this._gameCreateComplete.call(this._game); - if(this._onComplete !== null) { - this._onComplete.call(this._game.callbackContext); - } + this.onLoadComplete.dispatch(); } }; Loader.prototype.loadFile = /** @@ -7668,7 +7665,7 @@ var Phaser; file.url = this.getAudioURL(file.url); if(file.url !== null) { // WebAudio or Audio Tag? - if(this._game.sound.usingWebAudio) { + if(this.game.sound.usingWebAudio) { this._xhr.open("GET", file.url, true); this._xhr.responseType = "arraybuffer"; this._xhr.onload = function () { @@ -7678,8 +7675,8 @@ var Phaser; return _this.fileError(file.key); }; this._xhr.send(); - } else if(this._game.sound.usingAudioTag) { - if(this._game.sound.touchLocked) { + } else if(this.game.sound.usingAudioTag) { + if(this.game.sound.touchLocked) { // If audio is locked we can't do this yet, so need to queue this load request somehow. Bum. file.data = new Audio(); file.data.name = file.key; @@ -7694,7 +7691,7 @@ var Phaser; }; file.data.preload = 'auto'; file.data.src = file.url; - file.data.addEventListener('canplaythrough', Phaser.GAMES[this._game.id].load.fileComplete(file.key), false); + file.data.addEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete(file.key), false); file.data.load(); } } @@ -7718,9 +7715,7 @@ var Phaser; for(var i = 0; i < urls.length; i++) { extension = urls[i].toLowerCase(); extension = extension.substr((Math.max(0, extension.lastIndexOf(".")) || Infinity) + 1); - if(this._game.device.canPlayAudio(extension)) { - //console.log('getAudioURL', urls[i]); - //console.log(urls[i]); + if(this.game.device.canPlayAudio(extension)) { return urls[i]; } } @@ -7733,6 +7728,7 @@ var Phaser; function (key) { this._fileList[key].loaded = true; this._fileList[key].error = true; + this.onFileError.dispatch(key); throw new Error("Phaser.Loader error loading file: " + key); this.nextFile(key, false); }; @@ -7751,14 +7747,14 @@ var Phaser; var loadNext = true; switch(file.type) { case 'image': - this._game.cache.addImage(file.key, file.url, file.data); + this.game.cache.addImage(file.key, file.url, file.data); break; case 'spritesheet': - this._game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax); + this.game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax); break; case 'textureatlas': if(file.atlasURL == null) { - this._game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format); + this.game.cache.addTextureAtlas(file.key, file.url, file.data, file.atlasData, file.format); } else { // Load the JSON or XML before carrying on with the next file loadNext = false; @@ -7780,27 +7776,27 @@ var Phaser; } break; case 'audio': - if(this._game.sound.usingWebAudio) { + if(this.game.sound.usingWebAudio) { file.data = this._xhr.response; - this._game.cache.addSound(file.key, file.url, file.data, true, false); + this.game.cache.addSound(file.key, file.url, file.data, true, false); if(file.autoDecode) { - this._game.cache.updateSound(key, 'isDecoding', true); + this.game.cache.updateSound(key, 'isDecoding', true); var that = this; var key = file.key; - this._game.sound.context.decodeAudioData(file.data, function (buffer) { + this.game.sound.context.decodeAudioData(file.data, function (buffer) { if(buffer) { - that._game.cache.decodedSound(key, buffer); + that.game.cache.decodedSound(key, buffer); } }); } } else { - file.data.removeEventListener('canplaythrough', Phaser.GAMES[this._game.id].load.fileComplete); - this._game.cache.addSound(file.key, file.url, file.data, false, true); + file.data.removeEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete); + this.game.cache.addSound(file.key, file.url, file.data, false, true); } break; case 'text': file.data = this._xhr.response; - this._game.cache.addText(file.key, file.url, file.data); + this.game.cache.addText(file.key, file.url, file.data); break; } if(loadNext) { @@ -7814,7 +7810,7 @@ var Phaser; function (key) { var data = JSON.parse(this._xhr.response); var file = this._fileList[key]; - this._game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format); + this.game.cache.addTextureAtlas(file.key, file.url, file.data, data, file.format); this.nextFile(key, true); }; Loader.prototype.dataLoadError = /** @@ -7846,7 +7842,7 @@ var Phaser; throw new Error("Phaser.Loader. Invalid XML given"); } var file = this._fileList[key]; - this._game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format); + this.game.cache.addTextureAtlas(file.key, file.url, file.data, xml, file.format); this.nextFile(key, true); }; Loader.prototype.nextFile = /** @@ -7859,18 +7855,14 @@ var Phaser; if(this.progress > 100) { this.progress = 100; } - if(this._onFileLoad) { - this._onFileLoad.call(this._game.callbackContext, this.progress, previousKey, success); - } + this.onFileComplete.dispatch(this.progress, previousKey, success, this._queueSize - this._keys.length, this._queueSize); if(this._keys.length > 0) { this.loadFile(); } else { this.hasLoaded = true; + this.isLoading = false; this.removeAll(); - this._gameCreateComplete.call(this._game); - if(this._onComplete !== null) { - this._onComplete.call(this._game.callbackContext); - } + this.onLoadComplete.dispatch(); } }; Loader.prototype.checkKeyExists = /** @@ -7995,7 +7987,7 @@ var Phaser; */ function Cache(game) { this.onSoundUnlock = new Phaser.Signal(); - this._game = game; + this.game = game; this._canvases = { }; this._images = { @@ -8034,7 +8026,7 @@ var Phaser; frameWidth: frameWidth, frameHeight: frameHeight }; - this._images[key].frameData = Phaser.AnimationLoader.parseSpriteSheet(this._game, key, frameWidth, frameHeight, frameMax); + this._images[key].frameData = Phaser.AnimationLoader.parseSpriteSheet(this.game, key, frameWidth, frameHeight, frameMax); }; Cache.prototype.addTextureAtlas = /** * Add a new texture atlas. @@ -8050,9 +8042,9 @@ var Phaser; spriteSheet: true }; if(format == Phaser.Loader.TEXTURE_ATLAS_JSON_ARRAY) { - this._images[key].frameData = Phaser.AnimationLoader.parseJSONData(this._game, atlasData); + this._images[key].frameData = Phaser.AnimationLoader.parseJSONData(this.game, atlasData); } else if(format == Phaser.Loader.TEXTURE_ATLAS_XML_STARLING) { - this._images[key].frameData = Phaser.AnimationLoader.parseXMLData(this._game, atlasData, format); + this._images[key].frameData = Phaser.AnimationLoader.parseXMLData(this.game, atlasData, format); } }; Cache.prototype.addImage = /** @@ -8077,7 +8069,7 @@ var Phaser; function (key, url, data, webAudio, audioTag) { if (typeof webAudio === "undefined") { webAudio = true; } if (typeof audioTag === "undefined") { audioTag = false; } - var locked = this._game.sound.touchLocked; + var locked = this.game.sound.touchLocked; var decoded = false; if(audioTag) { decoded = true; @@ -9966,7 +9958,7 @@ var Phaser; * Helper for sort. */ this._sortIndex = ''; - this._game = game; + this.game = game; this._cameras = []; this._cameraLength = 0; this.defaultCamera = this.addCamera(x, y, width, height); @@ -10006,7 +9998,7 @@ var Phaser; * @returns {Camera} The newly created camera object. */ function (x, y, width, height) { - var newCam = new Phaser.Camera(this._game, this._cameraLength, x, y, width, height); + var newCam = new Phaser.Camera(this.game, this._cameraLength, x, y, width, height); this._cameraLength = this._cameras.push(newCam); return newCam; }; @@ -10089,7 +10081,7 @@ var Phaser; */ function () { this._cameras.length = 0; - this.current = this.addCamera(0, 0, this._game.stage.width, this._game.stage.height); + this.current = this.addCamera(0, 0, this.game.stage.width, this.game.stage.height); }; return CameraManager; })(); @@ -10529,9 +10521,9 @@ var Phaser; this._chainedTweens = []; this.isRunning = false; this._object = object; - this._game = game; - this._manager = this._game.tweens; - this._interpolationFunction = this._game.math.linearInterpolation; + this.game = game; + this._manager = this.game.tweens; + this._interpolationFunction = this.game.math.linearInterpolation; this._easingFunction = Phaser.Easing.Linear.None; this._chainedTweens = []; this.onStart = new Phaser.Signal(); @@ -10587,14 +10579,14 @@ var Phaser; */ function (looped) { if (typeof looped === "undefined") { looped = false; } - if(this._game === null || this._object === null) { + if(this.game === null || this._object === null) { return; } if(looped == false) { this._manager.add(this); this.onStart.dispatch(this._object); } - this._startTime = this._game.time.now + this._delayTime; + this._startTime = this.game.time.now + this._delayTime; this.isRunning = true; for(var property in this._valuesEnd) { // This prevents the interpolation of null values or of non-existing properties @@ -10656,8 +10648,8 @@ var Phaser; }; Object.defineProperty(Tween.prototype, "parent", { set: function (value) { - this._game = value; - this._manager = this._game.tweens; + this.game = value; + this._manager = this.game.tweens; }, enumerable: true, configurable: true @@ -10707,7 +10699,7 @@ var Phaser; * @return {boolean} Return false if this completed and no need to update, otherwise return true. */ function (time) { - if(this._game.paused == true) { + if(this.game.paused == true) { if(this._pausedTime == 0) { this._pausedTime = time; } @@ -11937,7 +11929,7 @@ var Phaser; * @type {boolean} */ this.separateY = true; - this._game = game; + this.game = game; this.tilemap = tilemap; this.index = index; this.width = width; @@ -12357,8 +12349,8 @@ var Phaser; * @param game {Game} A reference to the current Game. */ function GameObjectFactory(game) { - this._game = game; - this._world = this._game.world; + this.game = game; + this._world = this.game.world; } GameObjectFactory.prototype.camera = /** * Create a new camera with specific position and size. @@ -12380,7 +12372,7 @@ var Phaser; * @returns {GeomSprite} The newly created geom sprite object. */ //public geomSprite(x: number, y: number): GeomSprite { - // return this._world.group.add(new GeomSprite(this._game, x, y)); + // return this._world.group.add(new GeomSprite(this.game, x, y)); //} /** * Create a new Button game object. @@ -12404,7 +12396,7 @@ var Phaser; if (typeof overFrame === "undefined") { overFrame = null; } if (typeof outFrame === "undefined") { outFrame = null; } if (typeof downFrame === "undefined") { downFrame = null; } - return this._world.group.add(new Phaser.UI.Button(this._game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame)); + return this._world.group.add(new Phaser.UI.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame)); }; GameObjectFactory.prototype.sprite = /** * Create a new Sprite with specific position and sprite sheet key. @@ -12418,12 +12410,12 @@ var Phaser; function (x, y, key, frame) { if (typeof key === "undefined") { key = ''; } if (typeof frame === "undefined") { frame = null; } - return this._world.group.add(new Phaser.Sprite(this._game, x, y, key, frame)); + return this._world.group.add(new Phaser.Sprite(this.game, x, y, key, frame)); }; GameObjectFactory.prototype.audio = function (key, volume, loop) { if (typeof volume === "undefined") { volume = 1; } if (typeof loop === "undefined") { loop = false; } - return this._game.sound.add(key, volume, loop); + return this.game.sound.add(key, volume, loop); }; GameObjectFactory.prototype.dynamicTexture = /** * Create a new Sprite with the physics automatically created and set to DYNAMIC. The Sprite position offset is set to its center. @@ -12437,7 +12429,7 @@ var Phaser; * @returns {Sprite} The newly created sprite object. */ //public physicsSprite(x: number, y: number, key?: string = '', frame? = null, bodyType?: number = Phaser.Types.BODY_DYNAMIC, shapeType?:number = 0): Sprite { - // return this._world.group.add(new Sprite(this._game, x, y, key, frame, bodyType, shapeType)); + // return this._world.group.add(new Sprite(this.game, x, y, key, frame, bodyType, shapeType)); //} /** * Create a new DynamicTexture with specific size. @@ -12447,7 +12439,7 @@ var Phaser; * @returns {DynamicTexture} The newly created dynamic texture object. */ function (width, height) { - return new Phaser.DynamicTexture(this._game, width, height); + return new Phaser.DynamicTexture(this.game, width, height); }; GameObjectFactory.prototype.group = /** * Create a new object container. @@ -12457,7 +12449,7 @@ var Phaser; */ function (maxSize) { if (typeof maxSize === "undefined") { maxSize = 0; } - return this._world.group.add(new Phaser.Group(this._game, maxSize)); + return this._world.group.add(new Phaser.Group(this.game, maxSize)); }; GameObjectFactory.prototype.particle = /** * Create a new Particle. @@ -12465,7 +12457,7 @@ var Phaser; * @return {Particle} The newly created particle object. */ function () { - return new Phaser.ArcadeParticle(this._game); + return new Phaser.ArcadeParticle(this.game); }; GameObjectFactory.prototype.emitter = /** * Create a new Emitter. @@ -12479,7 +12471,7 @@ var Phaser; if (typeof x === "undefined") { x = 0; } if (typeof y === "undefined") { y = 0; } if (typeof size === "undefined") { size = 0; } - return this._world.group.add(new Phaser.ArcadeEmitter(this._game, x, y, size)); + return this._world.group.add(new Phaser.ArcadeEmitter(this.game, x, y, size)); }; GameObjectFactory.prototype.scrollZone = /** * Create a new ScrollZone object with image key, position and size. @@ -12496,7 +12488,7 @@ var Phaser; if (typeof y === "undefined") { y = 0; } if (typeof width === "undefined") { width = 0; } if (typeof height === "undefined") { height = 0; } - return this._world.group.add(new Phaser.ScrollZone(this._game, key, x, y, width, height)); + return this._world.group.add(new Phaser.ScrollZone(this.game, key, x, y, width, height)); }; GameObjectFactory.prototype.tilemap = /** * Create a new Tilemap. @@ -12513,7 +12505,7 @@ var Phaser; if (typeof resizeWorld === "undefined") { resizeWorld = true; } if (typeof tileWidth === "undefined") { tileWidth = 0; } if (typeof tileHeight === "undefined") { tileHeight = 0; } - return this._world.group.add(new Phaser.Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight)); + return this._world.group.add(new Phaser.Tilemap(this.game, key, mapData, format, resizeWorld, tileWidth, tileHeight)); }; GameObjectFactory.prototype.tween = /** * Create a tween object for a specific object. The object can be any JavaScript object or Phaser object such as Sprite. @@ -12524,7 +12516,7 @@ var Phaser; */ function (obj, localReference) { if (typeof localReference === "undefined") { localReference = false; } - return this._game.tweens.create(obj, localReference); + return this.game.tweens.create(obj, localReference); }; GameObjectFactory.prototype.existingSprite = /** * Add an existing Sprite to the current world. @@ -12604,7 +12596,7 @@ var Phaser; * @return {Phaser.Tween} The Tween object */ function (tween) { - return this._game.tweens.add(tween); + return this.game.tweens.add(tween); }; return GameObjectFactory; })(); @@ -13522,7 +13514,7 @@ var Phaser; * @type {number} */ this.maxIterations = 10; - this._game = game; + this.game = game; this.enterLandscape = new Phaser.Signal(); this.enterPortrait = new Phaser.Signal(); if(window['orientation']) { @@ -13565,7 +13557,7 @@ var Phaser; if(this.isFullScreen) { return; } - var element = this._game.stage.canvas; + var element = this.game.stage.canvas; if(element['requestFullScreen']) { element['requestFullScreen'](); } else if(element['mozRequestFullScreen']) { @@ -13587,7 +13579,7 @@ var Phaser; * The core update loop, called by Phaser.Stage */ function () { - if(this._game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height)) { + if(this.game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height)) { this.refresh(); } if(this.forceLandscape || this.forcePortrait) { @@ -13599,14 +13591,14 @@ var Phaser; if(this.incorrectOrientation) { if((this.forceLandscape && window.innerWidth > window.innerHeight) || (this.forcePortrait && window.innerHeight > window.innerWidth)) { // Back to normal - this._game.paused = false; + this.game.paused = false; this.incorrectOrientation = false; this.refresh(); } } else { if((this.forceLandscape && window.innerWidth < window.innerHeight) || (this.forcePortrait && window.innerHeight < window.innerWidth)) { // Show orientation screen - this._game.paused = true; + this.game.paused = true; this.incorrectOrientation = true; this.refresh(); } @@ -13636,7 +13628,7 @@ var Phaser; } else { this.enterPortrait.dispatch(this.orientation, false, true); } - if(this._game.stage.scaleMode !== StageScaleMode.NO_SCALE) { + if(this.game.stage.scaleMode !== StageScaleMode.NO_SCALE) { this.refresh(); } }; @@ -13654,7 +13646,7 @@ var Phaser; } else { this.enterPortrait.dispatch(this.orientation, false, true); } - if(this._game.stage.scaleMode !== StageScaleMode.NO_SCALE) { + if(this.game.stage.scaleMode !== StageScaleMode.NO_SCALE) { this.refresh(); } }; @@ -13664,10 +13656,10 @@ var Phaser; function () { var _this = this; // We can't do anything about the status bars in iPads, web apps or desktops - if(this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false) { + if(this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false) { document.documentElement.style.minHeight = '2000px'; this._startHeight = window.innerHeight; - if(this._game.device.android && this._game.device.chrome == false) { + if(this.game.device.android && this.game.device.chrome == false) { window.scrollTo(0, 1); } else { window.scrollTo(0, 0); @@ -13686,8 +13678,8 @@ var Phaser; */ function (force) { if (typeof force === "undefined") { force = false; } - if(this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false) { - if(this._game.device.android && this._game.device.chrome == false) { + if(this.game.device.iPad == false && this.game.device.webApp == false && this.game.device.desktop == false) { + if(this.game.device.android && this.game.device.chrome == false) { window.scrollTo(0, 1); } else { window.scrollTo(0, 0); @@ -13699,9 +13691,9 @@ var Phaser; document.documentElement.style.minHeight = window.innerHeight + 'px'; if(this.incorrectOrientation == true) { this.setMaximum(); - } else if(this._game.stage.scaleMode == StageScaleMode.EXACT_FIT) { + } else if(this.game.stage.scaleMode == StageScaleMode.EXACT_FIT) { this.setExactFit(); - } else if(this._game.stage.scaleMode == StageScaleMode.SHOW_ALL) { + } else if(this.game.stage.scaleMode == StageScaleMode.SHOW_ALL) { this.setShowAll(); } this.setSize(); @@ -13724,36 +13716,36 @@ var Phaser; this.height = this.minHeight; } } - this._game.stage.canvas.style.width = this.width + 'px'; - this._game.stage.canvas.style.height = this.height + 'px'; - this._game.input.scale.setTo(this._game.stage.width / this.width, this._game.stage.height / this.height); + this.game.stage.canvas.style.width = this.width + 'px'; + this.game.stage.canvas.style.height = this.height + 'px'; + this.game.input.scale.setTo(this.game.stage.width / this.width, this.game.stage.height / this.height); if(this.pageAlignHorizontally) { if(this.width < window.innerWidth && this.incorrectOrientation == false) { - this._game.stage.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px'; + this.game.stage.canvas.style.marginLeft = Math.round((window.innerWidth - this.width) / 2) + 'px'; } else { - this._game.stage.canvas.style.marginLeft = '0px'; + this.game.stage.canvas.style.marginLeft = '0px'; } } if(this.pageAlignVeritcally) { if(this.height < window.innerHeight && this.incorrectOrientation == false) { - this._game.stage.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px'; + this.game.stage.canvas.style.marginTop = Math.round((window.innerHeight - this.height) / 2) + 'px'; } else { - this._game.stage.canvas.style.marginTop = '0px'; + this.game.stage.canvas.style.marginTop = '0px'; } } - this._game.stage.getOffset(this._game.stage.canvas); + this.game.stage.getOffset(this.game.stage.canvas); this.aspectRatio = this.width / this.height; - this.scaleFactor.x = this._game.stage.width / this.width; - this.scaleFactor.y = this._game.stage.height / this.height; + this.scaleFactor.x = this.game.stage.width / this.width; + this.scaleFactor.y = this.game.stage.height / this.height; }; StageScaleMode.prototype.setMaximum = function () { this.width = window.innerWidth; this.height = window.innerHeight; }; StageScaleMode.prototype.setShowAll = function () { - var multiplier = Math.min((window.innerHeight / this._game.stage.height), (window.innerWidth / this._game.stage.width)); - this.width = Math.round(this._game.stage.width * multiplier); - this.height = Math.round(this._game.stage.height * multiplier); + var multiplier = Math.min((window.innerHeight / this.game.stage.height), (window.innerWidth / this.game.stage.width)); + this.width = Math.round(this.game.stage.width * multiplier); + this.height = Math.round(this.game.stage.height * multiplier); }; StageScaleMode.prototype.setExactFit = function () { if(this.maxWidth && window.innerWidth > this.maxWidth) { @@ -13813,7 +13805,7 @@ var Phaser; * @type {Phaser.Tween} */ this._fade = null; - this._game = game; + this.game = game; this._logo = new Image(); this._logo.src = this._logoData; } @@ -13835,36 +13827,36 @@ var Phaser; * Render BootScreen. */ function () { - var grd = this._game.stage.context.createLinearGradient(0, 0, 0, this._game.stage.height); + var grd = this.game.stage.context.createLinearGradient(0, 0, 0, this.game.stage.height); grd.addColorStop(0, 'rgb(' + this._color1.r + ', ' + this._color1.g + ', ' + this._color1.b + ')'); grd.addColorStop(0.5, 'rgb(' + this._color2.r + ', ' + this._color2.g + ', ' + this._color2.b + ')'); grd.addColorStop(1, 'rgb(' + this._color1.r + ', ' + this._color1.g + ', ' + this._color1.b + ')'); - this._game.stage.context.fillStyle = grd; - this._game.stage.context.fillRect(0, 0, this._game.stage.width, this._game.stage.height); - this._game.stage.context.shadowOffsetX = 0; - this._game.stage.context.shadowOffsetY = 0; + this.game.stage.context.fillStyle = grd; + this.game.stage.context.fillRect(0, 0, this.game.stage.width, this.game.stage.height); + this.game.stage.context.shadowOffsetX = 0; + this.game.stage.context.shadowOffsetY = 0; if(this._logo) { - this._game.stage.context.drawImage(this._logo, 32, 32); + this.game.stage.context.drawImage(this._logo, 32, 32); } - this._game.stage.context.shadowColor = 'rgb(0,0,0)'; - this._game.stage.context.shadowOffsetX = 1; - this._game.stage.context.shadowOffsetY = 1; - this._game.stage.context.shadowBlur = 0; - this._game.stage.context.fillStyle = 'rgb(255,255,255)'; - this._game.stage.context.font = 'bold 18px Arial'; - this._game.stage.context.textBaseline = 'top'; - this._game.stage.context.fillText(Phaser.VERSION, 32, 64 + 32); - this._game.stage.context.fillText('Game Size: ' + this._game.stage.width + ' x ' + this._game.stage.height, 32, 64 + 64); - this._game.stage.context.fillText('www.photonstorm.com', 32, 64 + 96); - this._game.stage.context.font = '16px Arial'; - this._game.stage.context.fillText('You are seeing this screen because you didn\'t specify any default', 32, 64 + 160); - this._game.stage.context.fillText('functions in the Game constructor or use Game.switchState()', 32, 64 + 184); + this.game.stage.context.shadowColor = 'rgb(0,0,0)'; + this.game.stage.context.shadowOffsetX = 1; + this.game.stage.context.shadowOffsetY = 1; + this.game.stage.context.shadowBlur = 0; + this.game.stage.context.fillStyle = 'rgb(255,255,255)'; + this.game.stage.context.font = 'bold 18px Arial'; + this.game.stage.context.textBaseline = 'top'; + this.game.stage.context.fillText(Phaser.VERSION, 32, 64 + 32); + this.game.stage.context.fillText('Game Size: ' + this.game.stage.width + ' x ' + this.game.stage.height, 32, 64 + 64); + this.game.stage.context.fillText('www.photonstorm.com', 32, 64 + 96); + this.game.stage.context.font = '16px Arial'; + this.game.stage.context.fillText('You are seeing this screen because you didn\'t specify any default', 32, 64 + 160); + this.game.stage.context.fillText('functions in the Game constructor or use Game.switchState()', 32, 64 + 184); }; BootScreen.prototype.colorCycle = /** * Start color fading cycle. */ function () { - this._fade = this._game.add.tween(this._color2); + this._fade = this.game.add.tween(this._color2); this._fade.to({ r: Math.random() * 250, g: Math.random() * 250, @@ -13894,7 +13886,7 @@ var Phaser; * @param height {number} Screen canvas height. */ function PauseScreen(game, width, height) { - this._game = game; + this.game = game; this._canvas = document.createElement('canvas'); this._canvas.width = width; this._canvas.height = height; @@ -13906,7 +13898,7 @@ var Phaser; function () { // Take a grab of the current canvas to our temporary one this._context.clearRect(0, 0, this._canvas.width, this._canvas.height); - this._context.drawImage(this._game.stage.canvas, 0, 0); + this._context.drawImage(this.game.stage.canvas, 0, 0); this._color = { r: 255, g: 255, @@ -13919,7 +13911,7 @@ var Phaser; */ function () { this._fade.stop(); - this._game.tweens.remove(this._fade); + this.game.tweens.remove(this._fade); }; PauseScreen.prototype.update = /** * Update background color. @@ -13933,27 +13925,27 @@ var Phaser; * Render PauseScreen. */ function () { - this._game.stage.context.drawImage(this._canvas, 0, 0); - this._game.stage.context.fillStyle = 'rgba(0, 0, 0, 0.4)'; - this._game.stage.context.fillRect(0, 0, this._game.stage.width, this._game.stage.height); + this.game.stage.context.drawImage(this._canvas, 0, 0); + this.game.stage.context.fillStyle = 'rgba(0, 0, 0, 0.4)'; + this.game.stage.context.fillRect(0, 0, this.game.stage.width, this.game.stage.height); // Draw a 'play' arrow - var arrowWidth = Math.round(this._game.stage.width / 2); - var arrowHeight = Math.round(this._game.stage.height / 2); - var sx = this._game.stage.centerX - arrowWidth / 2; - var sy = this._game.stage.centerY - arrowHeight / 2; - this._game.stage.context.beginPath(); - this._game.stage.context.moveTo(sx, sy); - this._game.stage.context.lineTo(sx, sy + arrowHeight); - this._game.stage.context.lineTo(sx + arrowWidth, this._game.stage.centerY); - this._game.stage.context.fillStyle = 'rgba(' + this._color.r + ', ' + this._color.g + ', ' + this._color.b + ', 0.8)'; - this._game.stage.context.fill(); - this._game.stage.context.closePath(); + var arrowWidth = Math.round(this.game.stage.width / 2); + var arrowHeight = Math.round(this.game.stage.height / 2); + var sx = this.game.stage.centerX - arrowWidth / 2; + var sy = this.game.stage.centerY - arrowHeight / 2; + this.game.stage.context.beginPath(); + this.game.stage.context.moveTo(sx, sy); + this.game.stage.context.lineTo(sx, sy + arrowHeight); + this.game.stage.context.lineTo(sx + arrowWidth, this.game.stage.centerY); + this.game.stage.context.fillStyle = 'rgba(' + this._color.r + ', ' + this._color.g + ', ' + this._color.b + ', 0.8)'; + this.game.stage.context.fill(); + this.game.stage.context.closePath(); }; PauseScreen.prototype.fadeOut = /** * Start fadeOut effect. */ function () { - this._fade = this._game.add.tween(this._color); + this._fade = this.game.add.tween(this._color); this._fade.to({ r: 50, g: 50, @@ -13966,7 +13958,7 @@ var Phaser; * Start fadeIn effect. */ function () { - this._fade = this._game.add.tween(this._color); + this._fade = this.game.add.tween(this._color); this._fade.to({ r: 255, g: 255, @@ -14079,13 +14071,7 @@ var Phaser; * @type {boolean} */ this.disableVisibilityChange = false; - /** - * An optional 'fix' for the horrendous Android stock browser bug - * https://code.google.com/p/android/issues/detail?id=39247 - * @type {boolean} - */ - this.patchAndroidClearRectBug = false; - this._game = game; + this.game = game; this.canvas = document.createElement('canvas'); this.canvas.width = width; this.canvas.height = height; @@ -14106,7 +14092,7 @@ var Phaser; this.context = this.canvas.getContext('2d'); this.css3 = new Phaser.Display.CSS3Filters(this.canvas); this.scaleMode = Phaser.StageScaleMode.NO_SCALE; - this.scale = new Phaser.StageScaleMode(this._game, width, height); + this.scale = new Phaser.StageScaleMode(this.game, width, height); this.getOffset(this.canvas); this.bounds = new Phaser.Rectangle(this.offset.x, this.offset.y, width, height); this.aspectRatio = width / height; @@ -14133,9 +14119,9 @@ var Phaser; * Stage boot */ function () { - this.bootScreen = new Phaser.BootScreen(this._game); - this.pauseScreen = new Phaser.PauseScreen(this._game, this.width, this.height); - this.orientationScreen = new Phaser.OrientationScreen(this._game); + this.bootScreen = new Phaser.BootScreen(this.game); + this.pauseScreen = new Phaser.PauseScreen(this.game, this.width, this.height); + this.orientationScreen = new Phaser.OrientationScreen(this.game); this.scale.setScreenSize(true); }; Stage.prototype.update = /** @@ -14145,24 +14131,24 @@ var Phaser; function () { this.scale.update(); this.context.setTransform(1, 0, 0, 1, 0, 0); - if(this.clear || (this._game.paused && this.disablePauseScreen == false)) { - if(this.patchAndroidClearRectBug) { + if(this.clear || (this.game.paused && this.disablePauseScreen == false)) { + if(this.game.device.patchAndroidClearRectBug) { this.context.fillStyle = 'rgb(0,0,0)'; this.context.fillRect(0, 0, this.width, this.height); } else { this.context.clearRect(0, 0, this.width, this.height); } } - if(this._game.paused && this.scale.incorrectOrientation) { + if(this.game.paused && this.scale.incorrectOrientation) { this.orientationScreen.update(); this.orientationScreen.render(); return; } - if(this._game.isRunning == false && this.disableBootScreen == false) { + if(this.game.isRunning == false && this.disableBootScreen == false) { this.bootScreen.update(); this.bootScreen.render(); } - if(this._game.paused && this.disablePauseScreen == false) { + if(this.game.paused && this.disablePauseScreen == false) { this.pauseScreen.update(); this.pauseScreen.render(); } @@ -14175,11 +14161,11 @@ var Phaser; return; } if(event.type == 'pagehide' || event.type == 'blur' || document['hidden'] == true || document['webkitHidden'] == true) { - if(this._game.paused == false) { + if(this.game.paused == false) { this.pauseGame(); } } else { - if(this._game.paused == true) { + if(this.game.paused == true) { this.resumeGame(); } } @@ -14192,7 +14178,7 @@ var Phaser; if(forceLandscape || forcePortrait) { if((this.scale.isLandscape && forcePortrait) || (this.scale.isPortrait && forceLandscape)) { // They are in the wrong orientation right now - this._game.paused = true; + this.game.paused = true; this.scale.incorrectOrientation = true; } else { this.scale.incorrectOrientation = false; @@ -14210,14 +14196,14 @@ var Phaser; this.pauseScreen.onPaused(); } this.saveCanvasValues(); - this._game.paused = true; + this.game.paused = true; }; Stage.prototype.resumeGame = function () { if(this.disablePauseScreen == false && this.pauseScreen) { this.pauseScreen.onResume(); } this.restoreCanvasValues(); - this._game.paused = false; + this.game.paused = false; }; Stage.prototype.getOffset = /** * Get the DOM offset values of the given element @@ -14251,7 +14237,7 @@ var Phaser; this.context.strokeStyle = this.strokeStyle; this.context.lineWidth = this.lineWidth; this.context.fillStyle = this.fillStyle; - if(this.patchAndroidClearRectBug) { + if(this.game.device.patchAndroidClearRectBug) { this.context.fillStyle = 'rgb(0,0,0)'; this.context.fillRect(0, 0, this.width, this.height); } else { @@ -14499,7 +14485,7 @@ var Phaser; * @param game {Game} A reference to the current Game. */ function TweenManager(game) { - this._game = game; + this.game = game; this._tweens = []; } TweenManager.prototype.getAll = /** @@ -14525,10 +14511,10 @@ var Phaser; function (object, localReference) { if (typeof localReference === "undefined") { localReference = false; } if(localReference) { - object['tween'] = new Phaser.Tween(object, this._game); + object['tween'] = new Phaser.Tween(object, this.game); return object['tween']; } else { - return new Phaser.Tween(object, this._game); + return new Phaser.Tween(object, this.game); } }; TweenManager.prototype.add = /** @@ -14538,7 +14524,7 @@ var Phaser; * @return {Phaser.Tween} The tween object you added to the manager. */ function (tween) { - tween.parent = this._game; + tween.parent = this.game; this._tweens.push(tween); return tween; }; @@ -14565,7 +14551,7 @@ var Phaser; var i = 0; var numTweens = this._tweens.length; while(i < numTweens) { - if(this._tweens[i].update(this._game.time.now)) { + if(this._tweens[i].update(this.game.time.now)) { i++; } else { this._tweens.splice(i, 1); @@ -14637,8 +14623,8 @@ var Phaser; * @type {Group} */ this._groupCounter = 0; - this._game = game; - this.cameras = new Phaser.CameraManager(this._game, 0, 0, width, height); + this.game = game; + this.cameras = new Phaser.CameraManager(this.game, 0, 0, width, height); this.bounds = new Phaser.Rectangle(0, 0, width, height); } World.prototype.getNextGroupID = function () { @@ -14648,7 +14634,7 @@ var Phaser; * Called once by Game during the boot process. */ function () { - this.group = new Phaser.Group(this._game, 0); + this.group = new Phaser.Group(this.game, 0); }; World.prototype.update = /** * This is called automatically every frame, and is where main logic happens. @@ -14683,7 +14669,7 @@ var Phaser; this.bounds.width = width; this.bounds.height = height; if(updateCameraBounds == true) { - this._game.camera.setBounds(0, 0, width, height); + this.game.camera.setBounds(0, 0, width, height); } // dispatch world resize event }; @@ -14761,6 +14747,13 @@ var Phaser; * Device constructor */ function Device() { + // Android bug specific :) + /** + * An optional 'fix' for the horrendous Android stock browser bug + * https://code.google.com/p/android/issues/detail?id=39247 + * @type {boolean} + */ + this.patchAndroidClearRectBug = false; // Operating System /** * Is running desktop? @@ -15221,7 +15214,7 @@ var Phaser; * @type Boolean **/ this.isRunning = false; - this._game = game; + this.game = game; this.callback = callback; var vendors = [ 'ms', @@ -15295,9 +15288,9 @@ var Phaser; **/ function (time) { var _this = this; - this._game.time.update(time); + this.game.time.update(time); if(this.callback) { - this.callback.call(this._game); + this.callback.call(this.game); } this._onLoop = function (time) { return _this.RAFUpdate(time); @@ -15310,13 +15303,13 @@ var Phaser; **/ function () { var _this = this; - this._game.time.update(Date.now()); + this.game.time.update(Date.now()); this._onLoop = function () { return _this.SetTimeoutUpdate(); }; this._timeOutID = window.setTimeout(this._onLoop, 16); if(this.callback) { - this.callback.call(this._game); + this.callback.call(this.game); } }; return RequestAnimationFrame; @@ -15824,6 +15817,9 @@ var Phaser; * @param {Any} event */ function (event) { + if(this.game.input.pollLocked) { + return; + } if(event.button) { this.button = event.button; } @@ -16133,20 +16129,20 @@ var Phaser; * @return {Touch} This object. */ function Gestures(game) { - this._game = game; + this.game = game; } Gestures.prototype.start = function () { // Local references to the Phaser.Input.pointer objects - this._p1 = this._game.input.pointer1; - this._p2 = this._game.input.pointer2; - this._p3 = this._game.input.pointer3; - this._p4 = this._game.input.pointer4; - this._p5 = this._game.input.pointer5; - this._p6 = this._game.input.pointer6; - this._p7 = this._game.input.pointer7; - this._p8 = this._game.input.pointer8; - this._p9 = this._game.input.pointer9; - this._p10 = this._game.input.pointer10; + this._p1 = this.game.input.pointer1; + this._p2 = this.game.input.pointer2; + this._p3 = this.game.input.pointer3; + this._p4 = this.game.input.pointer4; + this._p5 = this.game.input.pointer5; + this._p6 = this.game.input.pointer6; + this._p7 = this.game.input.pointer7; + this._p8 = this.game.input.pointer8; + this._p9 = this.game.input.pointer9; + this._p10 = this.game.input.pointer10; }; return Gestures; })(); @@ -16723,6 +16719,13 @@ var Phaser; (function (Phaser) { var InputManager = (function () { function InputManager(game) { + /** + * How often should the input pointers be checked for updates? + * A value of 0 means every single frame (60fps), a value of 1 means every other frame (30fps) and so on. + * @type {number} + */ + this.pollRate = 0; + this._pollCounter = 0; /** * A vector object representing the previous position of the Pointer. * @property vector @@ -17031,11 +17034,22 @@ var Phaser; this.inputObjects[index] = null; } }; + Object.defineProperty(InputManager.prototype, "pollLocked", { + get: function () { + return (this.pollRate > 0 && this._pollCounter < this.pollRate); + }, + enumerable: true, + configurable: true + }); InputManager.prototype.update = /** * Updates the Input Manager. Called by the core Game loop. * @method update **/ function () { + if(this.pollRate > 0 && this._pollCounter < this.pollRate) { + this._pollCounter++; + return; + } this.speed.x = this.position.x - this._oldPosition.x; this.speed.y = this.position.y - this._oldPosition.y; this._oldPosition.copyFrom(this.position); @@ -17066,6 +17080,7 @@ var Phaser; if(this.pointer10) { this.pointer10.update(); } + this._pollCounter = 0; }; InputManager.prototype.reset = /** * Reset all of the Pointers and Input states @@ -17100,6 +17115,7 @@ var Phaser; this.inputObjects.length = 0; this.totalTrackedObjects = 0; } + this._pollCounter = 0; }; InputManager.prototype.resetSpeed = function (x, y) { this._oldPosition.setTo(x, y); @@ -17347,7 +17363,12 @@ var Phaser; if(camera.visible == false || camera.transform.scale.x == 0 || camera.transform.scale.y == 0 || camera.texture.alpha < 0.1) { return false; } - camera.texture.context.clearRect(0, 0, camera.width, camera.height); + if(this.game.device.patchAndroidClearRectBug) { + camera.texture.context.fillStyle = 'rgb(0,0,0)'; + camera.texture.context.fillRect(0, 0, camera.width, camera.height); + } else { + camera.texture.context.clearRect(0, 0, camera.width, camera.height); + } // Alpha if(camera.texture.alpha !== 1 && camera.texture.context.globalAlpha != camera.texture.alpha) { this._ga = camera.texture.context.globalAlpha; @@ -18381,17 +18402,17 @@ var Phaser; * @param parent {string} ID of its parent DOM element. * @param width {number} The width of your game in game pixels. * @param height {number} The height of your game in game pixels. - * @param initCallback {function} Init callback invoked when init default screen. + * @param preloadCallback {function} Preload callback invoked when init default screen. * @param createCallback {function} Create callback invoked when create default screen. * @param updateCallback {function} Update callback invoked when update default screen. * @param renderCallback {function} Render callback invoked when render default screen. * @param destroyCallback {function} Destroy callback invoked when state is destroyed. */ - function Game(callbackContext, parent, width, height, initCallback, createCallback, updateCallback, renderCallback, destroyCallback) { + function Game(callbackContext, parent, width, height, preloadCallback, createCallback, updateCallback, renderCallback, destroyCallback) { if (typeof parent === "undefined") { parent = ''; } if (typeof width === "undefined") { width = 800; } if (typeof height === "undefined") { height = 600; } - if (typeof initCallback === "undefined") { initCallback = null; } + if (typeof preloadCallback === "undefined") { preloadCallback = null; } if (typeof createCallback === "undefined") { createCallback = null; } if (typeof updateCallback === "undefined") { updateCallback = null; } if (typeof renderCallback === "undefined") { renderCallback = null; } @@ -18401,7 +18422,7 @@ var Phaser; * Milliseconds of time per step of the game loop. * @type {number} */ - this._step = 0; + //private _step: number = 0; /** * Whether load complete loading or not. * @type {boolean} @@ -18426,7 +18447,7 @@ var Phaser; * This will be called when init states. (loading assets...) * @type {function} */ - this.onInitCallback = null; + this.onPreloadCallback = null; /** * This will be called when create states. (setup states...) * @type {function} @@ -18479,7 +18500,7 @@ var Phaser; this.isRunning = false; this.id = Phaser.GAMES.push(this) - 1; this.callbackContext = callbackContext; - this.onInitCallback = initCallback; + this.onPreloadCallback = preloadCallback; this.onCreateCallback = createCallback; this.onUpdateCallback = updateCallback; this.onRenderCallback = renderCallback; @@ -18518,7 +18539,7 @@ var Phaser; this.world = new Phaser.World(this, width, height); this.add = new Phaser.GameObjectFactory(this); this.cache = new Phaser.Cache(this); - this.load = new Phaser.Loader(this, this.loadComplete); + this.load = new Phaser.Loader(this); this.time = new Phaser.TimeManager(this); this.tweens = new Phaser.TweenManager(this); this.input = new Phaser.InputManager(this); @@ -18528,6 +18549,7 @@ var Phaser; ]); this.physics = new Phaser.Physics.Manager(this); this.plugins = new Phaser.PluginManager(this, this); + this.load.onLoadComplete.addOnce(this.loadComplete, this); this.setRenderer(Phaser.Types.RENDERER_CANVAS); this.world.boot(); this.stage.boot(); @@ -18538,7 +18560,7 @@ var Phaser; Phaser.ColorUtils.game = this; Phaser.DebugUtils.context = this.stage.context; // Display the default game screen? - if(this.onInitCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null) { + if(this.onPreloadCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null) { this._raf = new Phaser.RequestAnimationFrame(this, this.bootLoop); } else { this.isRunning = true; @@ -18565,10 +18587,11 @@ var Phaser; } }; Game.prototype.loadComplete = /** - * Called when the load has finished after init was run. + * Called when the load has finished after preload was run. */ function () { this._loadComplete = true; + this.onCreateCallback.call(this.callbackContext); }; Game.prototype.bootLoop = /** * The bootLoop is called while the game is still booting (waiting for the DOM and resources to be available) @@ -18629,15 +18652,18 @@ var Phaser; * Start current state. */ function () { - if(this.onInitCallback !== null) { + if(this.onPreloadCallback !== null) { this.load.reset(); - this.onInitCallback.call(this.callbackContext); - // Is the load empty? + this.onPreloadCallback.call(this.callbackContext); + // Is the loader empty? if(this.load.queueSize == 0) { if(this.onCreateCallback !== null) { this.onCreateCallback.call(this.callbackContext); } this._loadComplete = true; + } else { + // Start the loader going as we have something in the queue + this.load.start(); } } else { // No init? Then there was nothing to load either @@ -18649,19 +18675,19 @@ var Phaser; }; Game.prototype.setCallbacks = /** * Set the most common state callbacks (init, create, update, render). - * @param initCallback {function} Init callback invoked when init state. + * @param preloadCallback {function} Init callback invoked when init state. * @param createCallback {function} Create callback invoked when create state. * @param updateCallback {function} Update callback invoked when update state. * @param renderCallback {function} Render callback invoked when render state. * @param destroyCallback {function} Destroy callback invoked when state is destroyed. */ - function (initCallback, createCallback, updateCallback, renderCallback, destroyCallback) { - if (typeof initCallback === "undefined") { initCallback = null; } + function (preloadCallback, createCallback, updateCallback, renderCallback, destroyCallback) { + if (typeof preloadCallback === "undefined") { preloadCallback = null; } if (typeof createCallback === "undefined") { createCallback = null; } if (typeof updateCallback === "undefined") { updateCallback = null; } if (typeof renderCallback === "undefined") { renderCallback = null; } if (typeof destroyCallback === "undefined") { destroyCallback = null; } - this.onInitCallback = initCallback; + this.onPreloadCallback = preloadCallback; this.onCreateCallback = createCallback; this.onUpdateCallback = updateCallback; this.onRenderCallback = renderCallback; @@ -18692,7 +18718,7 @@ var Phaser; // Ok, have we got the right functions? if(this.state['create'] || this.state['update']) { this.callbackContext = this.state; - this.onInitCallback = null; + this.onPreloadCallback = null; this.onLoadRenderCallback = null; this.onLoadUpdateCallback = null; this.onCreateCallback = null; @@ -18702,8 +18728,8 @@ var Phaser; this.onPausedCallback = null; this.onDestroyCallback = null; // Bingo, let's set them up - if(this.state['init']) { - this.onInitCallback = this.state['init']; + if(this.state['preload']) { + this.onPreloadCallback = this.state['preload']; } if(this.state['loadRender']) { this.onLoadRenderCallback = this.state['loadRender']; @@ -18746,7 +18772,7 @@ var Phaser; */ function () { this.callbackContext = null; - this.onInitCallback = null; + this.onPreloadCallback = null; this.onLoadRenderCallback = null; this.onLoadUpdateCallback = null; this.onCreateCallback = null; @@ -18819,7 +18845,7 @@ var Phaser; * @param looped {boolean} Whether or not the animation is looped or just plays once. */ function Animation(game, parent, frameData, name, frames, delay, looped) { - this._game = game; + this.game = game; this._parent = parent; this._frames = frames; this._frameData = frameData; @@ -18872,8 +18898,8 @@ var Phaser; } this.isPlaying = true; this.isFinished = false; - this._timeLastFrame = this._game.time.now; - this._timeNextFrame = this._game.time.now + this.delay; + this._timeLastFrame = this.game.time.now; + this._timeNextFrame = this.game.time.now + this.delay; this._frameIndex = 0; this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); this._parent.events.onAnimationStart.dispatch(this._parent, this); @@ -18885,8 +18911,8 @@ var Phaser; function () { this.isPlaying = true; this.isFinished = false; - this._timeLastFrame = this._game.time.now; - this._timeNextFrame = this._game.time.now + this.delay; + this._timeLastFrame = this.game.time.now; + this._timeNextFrame = this.game.time.now + this.delay; this._frameIndex = 0; this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); }; @@ -18901,7 +18927,7 @@ var Phaser; * Update animation frames. */ function () { - if(this.isPlaying == true && this._game.time.now >= this._timeNextFrame) { + if(this.isPlaying == true && this.game.time.now >= this._timeNextFrame) { this._frameIndex++; if(this._frameIndex == this._frames.length) { if(this.looped) { @@ -18914,8 +18940,8 @@ var Phaser; } else { this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]); } - this._timeLastFrame = this._game.time.now; - this._timeNextFrame = this._game.time.now + this.delay; + this._timeLastFrame = this.game.time.now; + this._timeNextFrame = this.game.time.now + this.delay; return true; } return false; @@ -18924,7 +18950,7 @@ var Phaser; * Clean up animation memory. */ function () { - this._game = null; + this.game = null; this._parent = null; this._frames = null; this._frameData = null;