From 2f03f5fc436db129d3e60478af2d05a514b51b93 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 5 Jun 2013 02:58:16 +0100 Subject: [PATCH] Updated Loader component and fixed a few Pointer issues. --- Phaser/Game.ts | 16 +- Phaser/Stage.ts | 4 +- Phaser/State.ts | 4 +- Phaser/components/sprite/Input.ts | 21 +- Phaser/input/Input.ts | 2 +- Phaser/input/Pointer.ts | 70 +------ Phaser/loader/Loader.ts | 12 +- Phaser/sound/SoundManager.ts | 5 + README.md | 3 +- Tests/Tests.csproj | 28 +++ Tests/cameras/basic camera 1.js | 6 +- Tests/cameras/basic camera 1.ts | 6 +- Tests/cameras/scrollfactor 1.js | 6 +- Tests/cameras/scrollfactor 1.ts | 6 +- Tests/cameras/scrollfactor 2.js | 4 +- Tests/cameras/scrollfactor 2.ts | 4 +- Tests/demoscene/ballmover.js | 18 ++ Tests/demoscene/ballmover.ts | 31 +++ Tests/demoscene/colorwhirl.js | 22 ++ Tests/demoscene/colorwhirl.ts | 33 +++ Tests/demoscene/fruitfall.js | 44 ++++ Tests/demoscene/fruitfall.ts | 50 +++++ Tests/demoscene/fujiboink.js | 42 ++++ Tests/demoscene/fujiboink.ts | 56 +++++ Tests/demoscene/index.html | 32 +++ Tests/demoscene/metalslug.js | 22 ++ Tests/demoscene/metalslug.ts | 36 ++++ Tests/demoscene/scroller1.js | 12 ++ Tests/demoscene/scroller1.ts | 21 ++ Tests/demoscene/starray.js | 31 +++ Tests/demoscene/starray.ts | 53 +++++ Tests/groups/create group 1.js | 4 +- Tests/groups/create group 1.ts | 4 +- Tests/groups/display order.js | 8 +- Tests/groups/display order.ts | 8 +- Tests/groups/swap children.js | 6 +- Tests/groups/swap children.ts | 6 +- Tests/input/drag sprite 1.js | 4 +- Tests/input/drag sprite 1.ts | 5 +- Tests/input/drag sprite 2.js | 4 +- Tests/input/drag sprite 2.ts | 4 +- Tests/input/motion lock 2.js | 4 +- Tests/input/motion lock 2.ts | 4 +- Tests/input/motion lock.js | 4 +- Tests/input/motion lock.ts | 4 +- Tests/input/over sprite 1.js | 4 +- Tests/input/over sprite 1.ts | 4 +- Tests/input/over sprite 2.js | 4 +- Tests/input/over sprite 2.ts | 4 +- Tests/input/snap 1.js | 8 +- Tests/input/snap 1.ts | 8 +- Tests/input/touch priority.js | 8 +- Tests/input/touch priority.ts | 8 +- Tests/input/world drag.js | 6 +- Tests/input/world drag.ts | 6 +- Tests/mobile/sprite test 1.js | 8 +- Tests/mobile/sprite test 1.ts | 8 +- Tests/particles/graphic emitter.js | 4 +- Tests/particles/graphic emitter.ts | 4 +- Tests/particles/mousetrail.js | 6 +- Tests/particles/mousetrail.ts | 6 +- Tests/particles/multiple streams.js | 14 +- Tests/particles/multiple streams.ts | 14 +- Tests/particles/sprite emitter.js | 12 +- Tests/particles/sprite emitter.ts | 12 +- Tests/particles/when particles collide.js | 6 +- Tests/particles/when particles collide.ts | 6 +- Tests/phaser.js | 245 ++++++++-------------- Tests/physics/aabb 1.js | 4 +- Tests/physics/aabb 1.ts | 4 +- Tests/physics/aabb vs aabb 1.js | 6 +- Tests/physics/aabb vs aabb 1.ts | 6 +- Tests/scrollzones/ballscroller.js | 4 +- Tests/scrollzones/ballscroller.ts | 4 +- Tests/scrollzones/blasteroids.js | 10 +- Tests/scrollzones/blasteroids.ts | 10 +- Tests/scrollzones/parallax.js | 4 +- Tests/scrollzones/parallax.ts | 4 +- Tests/scrollzones/region demo.js | 4 +- Tests/scrollzones/region demo.ts | 4 +- Tests/scrollzones/scroll window.js | 6 +- Tests/scrollzones/scroll window.ts | 6 +- Tests/scrollzones/simple scrollzone.js | 4 +- Tests/scrollzones/simple scrollzone.ts | 4 +- Tests/scrollzones/skewed scroller.js | 4 +- Tests/scrollzones/skewed scroller.ts | 4 +- Tests/sprites/animation 1.js | 4 +- Tests/sprites/animation 1.ts | 4 +- Tests/sprites/animation 2.js | 4 +- Tests/sprites/animation 2.ts | 4 +- Tests/sprites/create sprite 1.js | 4 +- Tests/sprites/create sprite 1.ts | 4 +- Tests/sprites/scale sprite 1.js | 4 +- Tests/sprites/scale sprite 1.ts | 4 +- Tests/sprites/scale sprite 2.js | 4 +- Tests/sprites/scale sprite 2.ts | 4 +- Tests/sprites/scale sprite 3.js | 4 +- Tests/sprites/scale sprite 3.ts | 4 +- Tests/sprites/scale sprite 4.js | 4 +- Tests/sprites/scale sprite 4.ts | 4 +- Tests/sprites/scale sprite 5.js | 4 +- Tests/sprites/scale sprite 5.ts | 4 +- Tests/sprites/sprite origin 1.js | 4 +- Tests/sprites/sprite origin 1.ts | 4 +- Tests/sprites/sprite origin 2.js | 4 +- Tests/sprites/sprite origin 2.ts | 4 +- Tests/sprites/sprite origin 3.js | 4 +- Tests/sprites/sprite origin 3.ts | 4 +- Tests/sprites/sprite origin 4.js | 4 +- Tests/sprites/sprite origin 4.ts | 4 +- Tests/states/typescript/FakeGame.ts | 6 +- Tests/states/typescript/MainMenu.ts | 4 +- Tests/tweens/tween loop 1.js | 4 +- Tests/tweens/tween loop 1.ts | 4 +- Tests/tweens/tween loop 2.js | 4 +- Tests/tweens/tween loop 2.ts | 4 +- build/phaser.d.ts | 22 +- build/phaser.js | 126 +++-------- 118 files changed, 934 insertions(+), 602 deletions(-) create mode 100644 Tests/demoscene/ballmover.js create mode 100644 Tests/demoscene/ballmover.ts create mode 100644 Tests/demoscene/colorwhirl.js create mode 100644 Tests/demoscene/colorwhirl.ts create mode 100644 Tests/demoscene/fruitfall.js create mode 100644 Tests/demoscene/fruitfall.ts create mode 100644 Tests/demoscene/fujiboink.js create mode 100644 Tests/demoscene/fujiboink.ts create mode 100644 Tests/demoscene/index.html create mode 100644 Tests/demoscene/metalslug.js create mode 100644 Tests/demoscene/metalslug.ts create mode 100644 Tests/demoscene/scroller1.js create mode 100644 Tests/demoscene/scroller1.ts create mode 100644 Tests/demoscene/starray.js create mode 100644 Tests/demoscene/starray.ts diff --git a/Phaser/Game.ts b/Phaser/Game.ts index 76bdea63..52db70dc 100644 --- a/Phaser/Game.ts +++ b/Phaser/Game.ts @@ -101,7 +101,7 @@ module Phaser { private _step: number = 0; /** - * Whether loader complete loading or not. + * Whether load complete loading or not. * @type {boolean} */ private _loadComplete: bool = false; @@ -187,7 +187,7 @@ module Phaser { * Reference to the assets loader. * @type {Loader} */ - public loader: Loader; + public load: Loader; /** * Reference to the math helper. @@ -288,7 +288,7 @@ module Phaser { this.add = new GameObjectFactory(this); this.sound = new SoundManager(this); this.cache = new Cache(this); - this.loader = new Loader(this, this.loadComplete); + this.load = new Loader(this, this.loadComplete); this.time = new Time(this); this.tweens = new TweenManager(this); this.input = new Input(this); @@ -353,7 +353,7 @@ module Phaser { } /** - * Called when the loader has finished after init was run. + * Called when the load has finished after init was run. */ private loadComplete() { @@ -432,12 +432,12 @@ module Phaser { if (this.onInitCallback !== null) { - this.loader.reset(); + this.load.reset(); this.onInitCallback.call(this.callbackContext); - // Is the loader empty? - if (this.loader.queueSize == 0) + // Is the load empty? + if (this.load.queueSize == 0) { if (this.onCreateCallback !== null) { @@ -584,7 +584,7 @@ module Phaser { this.onDestroyCallback = null; this.cache = null; this.input = null; - this.loader = null; + this.load = null; this.sound = null; this.stage = null; this.time = null; diff --git a/Phaser/Stage.ts b/Phaser/Stage.ts index d38f84da..1dc5cdca 100644 --- a/Phaser/Stage.ts +++ b/Phaser/Stage.ts @@ -255,7 +255,7 @@ module Phaser { public pauseGame() { - if (this.disablePauseScreen == false) + if (this.disablePauseScreen == false && this.pauseScreen) { this.pauseScreen.onPaused(); } @@ -267,7 +267,7 @@ module Phaser { public resumeGame() { - if (this.disablePauseScreen == false) + if (this.disablePauseScreen == false && this.pauseScreen) { this.pauseScreen.onResume(); } diff --git a/Phaser/State.ts b/Phaser/State.ts index 86a925ea..99679557 100644 --- a/Phaser/State.ts +++ b/Phaser/State.ts @@ -22,7 +22,7 @@ module Phaser { this.camera = game.camera; this.cache = game.cache; this.input = game.input; - this.loader = game.loader; + this.load = game.load; this.math = game.math; this.motion = game.motion; this.sound = game.sound; @@ -66,7 +66,7 @@ module Phaser { * Reference to the assets loader. * @type {Loader} */ - public loader: Loader; + public load: Loader; /** * Reference to the math helper. diff --git a/Phaser/components/sprite/Input.ts b/Phaser/components/sprite/Input.ts index 91a9f89a..3e7dbe57 100644 --- a/Phaser/components/sprite/Input.ts +++ b/Phaser/components/sprite/Input.ts @@ -287,7 +287,7 @@ module Phaser.Components { } else { - this._pointOutHandler(pointer); + this._pointerOutHandler(pointer); return false; } } @@ -316,7 +316,7 @@ module Phaser.Components { } - public _pointOutHandler(pointer: Pointer) { + public _pointerOutHandler(pointer: Pointer) { this._pointerData[pointer.id].isOver = false; this._pointerData[pointer.id].isOut = true; @@ -335,11 +335,8 @@ module Phaser.Components { public _touchedHandler(pointer: Pointer): bool { - console.log('touched handler', this._pointerData[pointer.id]); - if (this._pointerData[pointer.id].isDown == false && this._pointerData[pointer.id].isOver == true) { - //console.log('touchDown on', this._sprite.texture.cacheKey,this._sprite.frameName, this._sprite.frameBounds.width,this._sprite.frameBounds.height); this._pointerData[pointer.id].isDown = true; this._pointerData[pointer.id].isUp = false; this._pointerData[pointer.id].timeDown = this.game.time.now; @@ -362,8 +359,6 @@ module Phaser.Components { public _releasedHandler(pointer: Pointer) { - console.log('release handler'); - // If was previously touched by this Pointer, check if still is if (this._pointerData[pointer.id].isDown && pointer.isUp) { @@ -562,7 +557,7 @@ module Phaser.Components { this._dragPoint.setTo(this._sprite.x - pointer.x, this._sprite.y - pointer.y); } - //pointer.draggedObject = this._sprite; + this.updateDrag(pointer); } @@ -678,13 +673,13 @@ module Phaser.Components { */ public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') { - this._sprite.texture.context.font = '16px Courier'; + this._sprite.texture.context.font = '14px Courier'; this._sprite.texture.context.fillStyle = color; this._sprite.texture.context.fillText('Sprite Input: (' + this._sprite.frameBounds.width + ' x ' + this._sprite.frameBounds.height + ')', x, y); - this._sprite.texture.context.fillText('x: ' + this.pointerX(1).toFixed(1) + ' y: ' + this.pointerY(1).toFixed(1), x, y + 14); - this._sprite.texture.context.fillText('over: ' + this.pointerOver(1) + ' duration: ' + this.overDuration(1).toFixed(0), x, y + 28); - this._sprite.texture.context.fillText('down: ' + this.pointerDown(1) + ' duration: ' + this.downDuration(1).toFixed(0), x, y + 42); - this._sprite.texture.context.fillText('just over: ' + this.justOver(1) + ' just out: ' + this.justOut(1), x, y + 56); + this._sprite.texture.context.fillText('x: ' + this.pointerX().toFixed(1) + ' y: ' + this.pointerY().toFixed(1), x, y + 14); + this._sprite.texture.context.fillText('over: ' + this.pointerOver() + ' duration: ' + this.overDuration().toFixed(0), x, y + 28); + this._sprite.texture.context.fillText('down: ' + this.pointerDown() + ' duration: ' + this.downDuration().toFixed(0), x, y + 42); + this._sprite.texture.context.fillText('just over: ' + this.justOver() + ' just out: ' + this.justOut(), x, y + 56); } diff --git a/Phaser/input/Input.ts b/Phaser/input/Input.ts index 7ba45d64..5153f9f3 100644 --- a/Phaser/input/Input.ts +++ b/Phaser/input/Input.ts @@ -904,7 +904,7 @@ module Phaser { */ public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') { - this._game.stage.context.font = '24px Courier'; + this._game.stage.context.font = '14px Courier'; this._game.stage.context.fillStyle = color; this._game.stage.context.fillText('Input', x, y); this._game.stage.context.fillText('Screen X: ' + this.x + ' Screen Y: ' + this.y, x, y + 14); diff --git a/Phaser/input/Pointer.ts b/Phaser/input/Pointer.ts index bd66bc01..ef44917f 100644 --- a/Phaser/input/Pointer.ts +++ b/Phaser/input/Pointer.ts @@ -348,29 +348,6 @@ module Phaser { this.game.input.currentPointers++; } - // Build our temporary click stack - /* - var _highestPriority = 0; - var _highestRenderID = 0; - var _highestRenderObject: number = -1; - - for (var i = 0; i < this.game.input.totalTrackedObjects; i++) - { - if (this.game.input.inputObjects[i].input.checkPointerOver(this) && this.game.input.inputObjects[i].renderOrderID > _highestRenderID) - { - _highestRenderID = this.game.input.inputObjects[i].renderOrderID; - _highestRenderObject = i; - } - } - - if (_highestRenderObject !== -1 && this._stateReset == false) - { - this.targetObject = this.game.input.inputObjects[_highestRenderObject]; - this.targetObject.input._touchedHandler(this); - //_highestRenderObject.input._touchedHandler(this); - } - */ - if (this.targetObject !== null) { this.targetObject.input._touchedHandler(this); @@ -406,50 +383,6 @@ module Phaser { } } - // Iterate through the tracked objects - - // Build our temporary click stack - /* - var _highestPriority = 0; - var _highestRenderID = 0; - var _highestRenderObject = null; - - for (var i = 0; i < this.game.input.totalTrackedObjects; i++) - { - if (this.game.input.inputObjects[i].input.enabled) - { - //if (this.game.input.inputObjects[i].input.update(this) && this.game.input.inputObjects[i].input.priorityID > _highestPriority) - if (this.game.input.inputObjects[i].input.update(this) && this.game.input.inputObjects[i].renderOrderID > _highestRenderID) - { - _highestRenderID = this.game.input.inputObjects[i].renderOrderID; - _highestRenderObject = this.game.input.inputObjects[i]; - } - } - } - - if (_highestRenderObject !== null) - { - _highestRenderObject.input._pointerOverHandler(this); - - if (this.isDown && this._stateReset == false) - { - _highestRenderObject.input._touchedHandler(this); - } - - // Now update all objects with the highest priority ID (can be more than 1) - //for (var i = 0; i < this.game.input.totalTrackedObjects; i++) - //{ - // if (this.game.input.inputObjects[i].input.priorityID == _highestPriority) - // { - // if (this.game.input.inputObjects[i].input._touchedHandler(this) == false) - // { - // return; - // } - // } - //} - } - */ - } } @@ -499,7 +432,7 @@ module Phaser { else { // Build our temporary click stack - var _highestRenderID = 0; + var _highestRenderID = -1; var _highestRenderObject: number = -1; for (var i = 0; i < this.game.input.totalTrackedObjects; i++) @@ -517,6 +450,7 @@ module Phaser { this.targetObject = this.game.input.inputObjects[_highestRenderObject]; this.targetObject.input._pointerOverHandler(this); } + } return this; diff --git a/Phaser/loader/Loader.ts b/Phaser/loader/Loader.ts index 509f9edd..d7acf982 100644 --- a/Phaser/loader/Loader.ts +++ b/Phaser/loader/Loader.ts @@ -107,7 +107,7 @@ module Phaser { * @param key {string} Unique asset key of this image file. * @param url {string} URL of image file. */ - public addImageFile(key: string, url: string) { + public image(key: string, url: string) { if (this.checkKeyExists(key) === false) { @@ -126,7 +126,7 @@ module Phaser { * @param frameHeight {number} Height of each single frame. * @param frameMax {number} How many frames in this sprite sheet. */ - public addSpriteSheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax?: number = -1) { + public spritesheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax?: number = -1) { if (this.checkKeyExists(key) === false) { @@ -145,7 +145,7 @@ module Phaser { * @param [atlasData] {object} A JSON or XML data object. * @param [format] {number} A value describing the format of the data. */ - public addTextureAtlas(key: string, textureURL: string, atlasURL?: string = null, atlasData? = null, format?:number = Loader.TEXTURE_ATLAS_JSON_ARRAY) { + public atlas(key: string, textureURL: string, atlasURL?: string = null, atlasData? = null, format?:number = Loader.TEXTURE_ATLAS_JSON_ARRAY) { if (this.checkKeyExists(key) === false) { @@ -222,7 +222,7 @@ module Phaser { * @param key {string} Unique asset key of the audio file. * @param url {string} URL of audio file. */ - public addAudioFile(key: string, url: string) { + public audio(key: string, url: string) { if (this.checkKeyExists(key) === false) { @@ -238,7 +238,7 @@ module Phaser { * @param key {string} Unique asset key of the text file. * @param url {string} URL of text file. */ - public addTextFile(key: string, url: string) { + public text(key: string, url: string) { if (this.checkKeyExists(key) === false) { @@ -273,7 +273,7 @@ module Phaser { * @param onFileLoadCallback {function} Called when each file loaded successfully. * @param onCompleteCallback {function} Called when all assets completely loaded. */ - public load(onFileLoadCallback = null, onCompleteCallback = null) { + public start(onFileLoadCallback = null, onCompleteCallback = null) { this.progress = 0; this.hasLoaded = false; diff --git a/Phaser/sound/SoundManager.ts b/Phaser/sound/SoundManager.ts index 5b6d9eba..9e39e33c 100644 --- a/Phaser/sound/SoundManager.ts +++ b/Phaser/sound/SoundManager.ts @@ -19,6 +19,11 @@ module Phaser { this._game = game; + if (window['PhaserGlobal'] && window['PhaserGlobal'].disableAudio == true) + { + return; + } + if (game.device.webaudio == true) { if (!!window['AudioContext']) diff --git a/README.md b/README.md index a6e071e0..8e8d0068 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ TODO: * Bug in AnimationManager set frame/frameName - the width/height are trimmed and wrong * RenderOrderID won't work across cameras - but then neither do Pointers yet anyway * Swap to using time based motion (like the tweens) rather than delta timer - it just doesn't work well on slow phones - +* Bug in World drag V1.0.0 @@ -90,6 +90,7 @@ V1.0.0 * Added support for minWidth and minHeight to game scale size, so it can never go below those values when scaling. * Vastly improved orientation detection and response speed. * Added custom callback support for all Touch and Mouse Events so you can easily hook events to custom APIs. +* Updated Game.loader and its methods. You now load images by: game.load.image() and also: game.load.atlas, game.load.audio, game.load.spritesheet, game.load.text. And you start it with game.load.start(). diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 00cc3f81..780c76f3 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -69,6 +69,34 @@ + + + ballmover.ts + + + + + colorwhirl.ts + + + + + fruitfall.ts + + + fujiboink.ts + + + + metalslug.ts + + + scroller1.ts + + + + starray.ts + create group 1.ts diff --git a/Tests/cameras/basic camera 1.js b/Tests/cameras/basic camera 1.js index 154d8c69..3a601655 100644 --- a/Tests/cameras/basic camera 1.js +++ b/Tests/cameras/basic camera 1.js @@ -3,9 +3,9 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); function init() { game.world.setSize(1920, 1200, true); - game.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg'); - game.loader.addImageFile('melon', 'assets/sprites/melon.png'); - game.loader.load(); + game.load.image('backdrop', 'assets/pics/remember-me.jpg'); + game.load.image('melon', 'assets/sprites/melon.png'); + game.load.start(); } function create() { game.add.sprite(0, 0, 'backdrop'); diff --git a/Tests/cameras/basic camera 1.ts b/Tests/cameras/basic camera 1.ts index 2039e409..b5b3f22d 100644 --- a/Tests/cameras/basic camera 1.ts +++ b/Tests/cameras/basic camera 1.ts @@ -8,10 +8,10 @@ game.world.setSize(1920, 1200, true); - game.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg'); - game.loader.addImageFile('melon', 'assets/sprites/melon.png'); + game.load.image('backdrop', 'assets/pics/remember-me.jpg'); + game.load.image('melon', 'assets/sprites/melon.png'); - game.loader.load(); + game.load.start(); } diff --git a/Tests/cameras/scrollfactor 1.js b/Tests/cameras/scrollfactor 1.js index e334cf27..5f7cd17a 100644 --- a/Tests/cameras/scrollfactor 1.js +++ b/Tests/cameras/scrollfactor 1.js @@ -3,9 +3,9 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); function init() { game.world.setSize(1920, 1200, true); - game.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg'); - game.loader.addImageFile('ball', 'assets/sprites/shinyball.png'); - game.loader.load(); + 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 5b41cfd1..4125ff45 100644 --- a/Tests/cameras/scrollfactor 1.ts +++ b/Tests/cameras/scrollfactor 1.ts @@ -8,10 +8,10 @@ game.world.setSize(1920, 1200, true); - game.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg'); - game.loader.addImageFile('ball', 'assets/sprites/shinyball.png'); + game.load.image('backdrop', 'assets/pics/remember-me.jpg'); + game.load.image('ball', 'assets/sprites/shinyball.png'); - game.loader.load(); + game.load.start(); } diff --git a/Tests/cameras/scrollfactor 2.js b/Tests/cameras/scrollfactor 2.js index 7e3e137b..dedbfeac 100644 --- a/Tests/cameras/scrollfactor 2.js +++ b/Tests/cameras/scrollfactor 2.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); function init() { game.world.setSize(1600, 800, true); - game.loader.addImageFile('disk', 'assets/pics/devilstar_demo_download_disk.png'); - game.loader.load(); + 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 d8fcbde6..f25abcdc 100644 --- a/Tests/cameras/scrollfactor 2.ts +++ b/Tests/cameras/scrollfactor 2.ts @@ -8,9 +8,9 @@ game.world.setSize(1600, 800, true); - game.loader.addImageFile('disk', 'assets/pics/devilstar_demo_download_disk.png'); + game.load.image('disk', 'assets/pics/devilstar_demo_download_disk.png'); - game.loader.load(); + game.load.start(); } diff --git a/Tests/demoscene/ballmover.js b/Tests/demoscene/ballmover.js new file mode 100644 index 00000000..e45c4c6d --- /dev/null +++ b/Tests/demoscene/ballmover.js @@ -0,0 +1,18 @@ +/// +/// +(function () { + var game = new Phaser.Game(this, 'demo1', 320, 200, init, create, update); + function init() { + game.load.image('balls', '../assets/sprites/balls.png'); + game.load.start(); + } + var scroller; + function create() { + scroller = game.add.scrollZone('balls', 0, 0, 800, 612); + game.math.sinCosGenerator(256, 4, 4, 2); + } + function update() { + scroller.currentRegion.scrollSpeed.x = game.math.shiftSinTable(); + scroller.currentRegion.scrollSpeed.y = game.math.shiftCosTable(); + } +})(); diff --git a/Tests/demoscene/ballmover.ts b/Tests/demoscene/ballmover.ts new file mode 100644 index 00000000..d1775dae --- /dev/null +++ b/Tests/demoscene/ballmover.ts @@ -0,0 +1,31 @@ +/// +/// + +(function () { + + var game = new Phaser.Game(this, 'demo1', 320, 200, init, create, update); + + function init() { + + game.load.image('balls', '../assets/sprites/balls.png'); + game.load.start(); + + } + + var scroller: Phaser.ScrollZone; + + function create() { + + scroller = game.add.scrollZone('balls', 0, 0, 800, 612); + game.math.sinCosGenerator(256, 4, 4, 2); + + } + + function update() { + + scroller.currentRegion.scrollSpeed.x = game.math.shiftSinTable(); + scroller.currentRegion.scrollSpeed.y = game.math.shiftCosTable(); + + } + +})(); diff --git a/Tests/demoscene/colorwhirl.js b/Tests/demoscene/colorwhirl.js new file mode 100644 index 00000000..51595fdd --- /dev/null +++ b/Tests/demoscene/colorwhirl.js @@ -0,0 +1,22 @@ +/// +(function () { + var game = new Phaser.Game(this, 'game', 320, 200, init, create); + function init() { + // 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() { + // Here we'll assign the new sprite to the local swirl variable + swirl = game.add.sprite(game.stage.centerX, game.stage.centerY, 'swirl'); + // Increase the size of the sprite a little so it covers the edges of the stage + swirl.scale.setTo(1.4, 1.4); + // Set the origin to the middle of the Sprite to get the effect we need + swirl.origin.setTo(swirl.frameBounds.halfWidth, swirl.frameBounds.halfHeight); + // Create a tween that rotates a full 306 degrees and then repeats (loop set to true) + game.add.tween(swirl).to({ + angle: 360 + }, 2000, Phaser.Easing.Linear.None, true, 0, true); + } +})(); diff --git a/Tests/demoscene/colorwhirl.ts b/Tests/demoscene/colorwhirl.ts new file mode 100644 index 00000000..e4fa1a7e --- /dev/null +++ b/Tests/demoscene/colorwhirl.ts @@ -0,0 +1,33 @@ +/// + +(function () { + + var game = new Phaser.Game(this, 'game', 320, 200, init, create); + + function init() { + + // 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: Phaser.Sprite; + + function create() { + + // Here we'll assign the new sprite to the local swirl variable + swirl = game.add.sprite(game.stage.centerX, game.stage.centerY, 'swirl'); + + // Increase the size of the sprite a little so it covers the edges of the stage + swirl.scale.setTo(1.4, 1.4); + + // Set the origin to the middle of the Sprite to get the effect we need + swirl.origin.setTo(swirl.frameBounds.halfWidth, swirl.frameBounds.halfHeight); + + // Create a tween that rotates a full 306 degrees and then repeats (loop set to true) + game.add.tween(swirl).to({ angle: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true); + + } + +})(); diff --git a/Tests/demoscene/fruitfall.js b/Tests/demoscene/fruitfall.js new file mode 100644 index 00000000..7487c527 --- /dev/null +++ b/Tests/demoscene/fruitfall.js @@ -0,0 +1,44 @@ +var __extends = this.__extends || function (d, b) { + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +/// +/// +/// +var fruitParticle = (function (_super) { + __extends(fruitParticle, _super); + function fruitParticle(game) { + _super.call(this, game); + var s = [ + 'carrot', + 'melon', + 'eggplant', + 'mushroom', + 'pineapple' + ]; + this.texture.loadImage(game.math.getRandom(s)); + } + return fruitParticle; +})(Phaser.Particle); +(function () { + var game = new Phaser.Game(this, 'game', 320, 200, init, create); + var emitter; + function init() { + 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); + emitter.gravity = 100; + // Here we tell the emitter to use our customParticle class + // The customParticle needs to extend Particle and must take game:Game as the first constructor parameter, otherwise it's free as a bird + emitter.particleClass = fruitParticle; + emitter.makeParticles(null, 50, false, 0); + emitter.start(false, 10, 0.05); + } +})(); diff --git a/Tests/demoscene/fruitfall.ts b/Tests/demoscene/fruitfall.ts new file mode 100644 index 00000000..19ed08b7 --- /dev/null +++ b/Tests/demoscene/fruitfall.ts @@ -0,0 +1,50 @@ +/// +/// +/// + +class fruitParticle extends Phaser.Particle { + + constructor(game:Phaser.Game) { + + super(game); + + var s = ['carrot', 'melon', 'eggplant', 'mushroom', 'pineapple']; + + this.texture.loadImage(game.math.getRandom(s)); + } + +} + +(function () { + + var game = new Phaser.Game(this, 'game', 320, 200, init, create); + + var emitter: Phaser.Emitter; + + function init() { + + 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); + emitter.gravity = 100; + + // Here we tell the emitter to use our customParticle class + // The customParticle needs to extend Particle and must take game:Game as the first constructor parameter, otherwise it's free as a bird + emitter.particleClass = fruitParticle; + + emitter.makeParticles(null, 50, false, 0); + emitter.start(false, 10, 0.05); + + } + +})(); diff --git a/Tests/demoscene/fujiboink.js b/Tests/demoscene/fujiboink.js new file mode 100644 index 00000000..3817e311 --- /dev/null +++ b/Tests/demoscene/fujiboink.js @@ -0,0 +1,42 @@ +/// +(function () { + var game = new Phaser.Game(this, 'game', 320, 200, init, create); + function init() { + // 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; + var tweenDown; + function create() { + game.stage.backgroundColor = 'rgb(0,0,100)'; + // Here we'll assign the new sprite to the local fuji variable + fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji'); + // The sprite is 320 x 200 pixels in size + // Here we set the origin to the center of the sprite again, so we can rotate and scale it at the same time + fuji.origin.setTo(160, 100); + game.add.tween(fuji).to({ + angle: 360 + }, 2000, Phaser.Easing.Linear.None, true, 0, true); + tweenUp = game.add.tween(fuji.scale); + tweenUp.onComplete.add(scaleDown, this); + tweenDown = game.add.tween(fuji.scale); + tweenDown.onComplete.add(scaleUp, this); + scaleUp(); + } + function scaleUp() { + tweenUp.to({ + x: 2, + y: 2 + }, 1000, Phaser.Easing.Elastic.Out); + tweenUp.start(); + } + function scaleDown() { + tweenDown.to({ + x: 0.5, + y: 0.5 + }, 1000, Phaser.Easing.Elastic.Out); + tweenDown.start(); + } +})(); diff --git a/Tests/demoscene/fujiboink.ts b/Tests/demoscene/fujiboink.ts new file mode 100644 index 00000000..7f8ec442 --- /dev/null +++ b/Tests/demoscene/fujiboink.ts @@ -0,0 +1,56 @@ +/// + +(function () { + + var game = new Phaser.Game(this, 'game', 320, 200, init, create); + + function init() { + + // 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: Phaser.Sprite; + var tweenUp: Phaser.Tween; + var tweenDown: Phaser.Tween; + + function create() { + + game.stage.backgroundColor = 'rgb(0,0,100)'; + + // Here we'll assign the new sprite to the local fuji variable + fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji'); + + // The sprite is 320 x 200 pixels in size + // Here we set the origin to the center of the sprite again, so we can rotate and scale it at the same time + fuji.origin.setTo(160, 100); + + game.add.tween(fuji).to({ angle: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true); + + tweenUp = game.add.tween(fuji.scale); + tweenUp.onComplete.add(scaleDown, this); + + tweenDown = game.add.tween(fuji.scale); + tweenDown.onComplete.add(scaleUp, this); + + scaleUp(); + + } + + function scaleUp() { + + tweenUp.to({ x: 2, y: 2 }, 1000, Phaser.Easing.Elastic.Out); + tweenUp.start(); + + } + + function scaleDown() { + + tweenDown.to({ x: 0.5, y: 0.5 }, 1000, Phaser.Easing.Elastic.Out); + tweenDown.start(); + + } + +})(); diff --git a/Tests/demoscene/index.html b/Tests/demoscene/index.html new file mode 100644 index 00000000..f36772f0 --- /dev/null +++ b/Tests/demoscene/index.html @@ -0,0 +1,32 @@ + + + + + + Phaser does DemoScene + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tests/demoscene/metalslug.js b/Tests/demoscene/metalslug.js new file mode 100644 index 00000000..09d42f06 --- /dev/null +++ b/Tests/demoscene/metalslug.js @@ -0,0 +1,22 @@ +/// +(function () { + var game = new Phaser.Game(this, 'game', 320, 200, init, create); + function init() { + // 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() { + game.stage.backgroundColor = 'rgb(50,10,10)'; + // Notice the use of 'stage.centerX' - this places the sprite in the middle of the stage without needing to do any extra math + monster = game.add.sprite(100, 50, 'monster'); + // For this animation we pass 'null' for the frames, because we're going to use them all + // And we set the frame rate (30) and loop status (true) when we add the animation + // If the frame rate and looping is never going to change then it's easier to do it here + monster.animations.add('walk', null, 30, true); + // Then you can just call 'play' on its own with no other values to start things going + monster.animations.play('walk'); + monster.scale.setTo(3, 3); + } +})(); diff --git a/Tests/demoscene/metalslug.ts b/Tests/demoscene/metalslug.ts new file mode 100644 index 00000000..020973ca --- /dev/null +++ b/Tests/demoscene/metalslug.ts @@ -0,0 +1,36 @@ +/// + +(function () { + + var game = new Phaser.Game(this, 'game', 320, 200, init, create); + + function init() { + + // 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: Phaser.Sprite; + + function create() { + + game.stage.backgroundColor = 'rgb(50,10,10)'; + + // Notice the use of 'stage.centerX' - this places the sprite in the middle of the stage without needing to do any extra math + monster = game.add.sprite(100, 50, 'monster'); + + // For this animation we pass 'null' for the frames, because we're going to use them all + // And we set the frame rate (30) and loop status (true) when we add the animation + // If the frame rate and looping is never going to change then it's easier to do it here + monster.animations.add('walk', null, 30, true); + + // Then you can just call 'play' on its own with no other values to start things going + monster.animations.play('walk'); + + monster.scale.setTo(3, 3); + + } + +})(); diff --git a/Tests/demoscene/scroller1.js b/Tests/demoscene/scroller1.js new file mode 100644 index 00000000..d43079cd --- /dev/null +++ b/Tests/demoscene/scroller1.js @@ -0,0 +1,12 @@ +/// +/// +(function () { + var game = new Phaser.Game(this, 'game', 320, 200, init, create); + function init() { + game.load.image('crystal', '../assets/pics/jim_sachs_time_crystal.png'); + game.load.start(); + } + function create() { + game.add.scrollZone('crystal').setSpeed(4, 2); + } +})(); diff --git a/Tests/demoscene/scroller1.ts b/Tests/demoscene/scroller1.ts new file mode 100644 index 00000000..6bf30f32 --- /dev/null +++ b/Tests/demoscene/scroller1.ts @@ -0,0 +1,21 @@ +/// +/// + +(function () { + + var game = new Phaser.Game(this, 'game', 320, 200, init, create); + + function init() { + + game.load.image('crystal', '../assets/pics/jim_sachs_time_crystal.png'); + game.load.start(); + + } + + function create() { + + game.add.scrollZone('crystal').setSpeed(4, 2); + + } + +})(); diff --git a/Tests/demoscene/starray.js b/Tests/demoscene/starray.js new file mode 100644 index 00000000..44c4601a --- /dev/null +++ b/Tests/demoscene/starray.js @@ -0,0 +1,31 @@ +/// +/// +(function () { + var game = new Phaser.Game(this, 'game', 320, 200, init, create); + function init() { + game.load.image('starray', '../assets/pics/auto_scroll_landscape.png'); + game.load.start(); + } + function create() { + var zone = game.add.scrollZone('starray'); + // Hide the default region (the full image) + zone.currentRegion.visible = false; + var y = 0; + var speed = 16; + // The image consists of 10px high scrolling layers, this creates them quickly (top = fastest, getting slower as we move down) + for(var z = 0; z < 32; z++) { + zone.addRegion(0, y, 640, 10, speed); + if(z <= 15) { + speed -= 1; + } else { + speed += 1; + } + if(z == 15) { + y = 240; + speed += 1; + } else { + y += 10; + } + } + } +})(); diff --git a/Tests/demoscene/starray.ts b/Tests/demoscene/starray.ts new file mode 100644 index 00000000..dc61ab98 --- /dev/null +++ b/Tests/demoscene/starray.ts @@ -0,0 +1,53 @@ +/// +/// + +(function () { + + var game = new Phaser.Game(this, 'game', 320, 200, init, create); + + function init() { + + game.load.image('starray', '../assets/pics/auto_scroll_landscape.png'); + + game.load.start(); + + } + + function create() { + + var zone: Phaser.ScrollZone = game.add.scrollZone('starray'); + + // Hide the default region (the full image) + zone.currentRegion.visible = false; + + var y:number = 0; + var speed:number = 16; + + // The image consists of 10px high scrolling layers, this creates them quickly (top = fastest, getting slower as we move down) + for (var z:number = 0; z < 32; z++) + { + zone.addRegion(0, y, 640, 10, speed); + + if (z <= 15) + { + speed -= 1; + } + else + { + speed += 1; + } + + if (z == 15) + { + y = 240; + speed += 1; + } + else + { + y += 10; + } + } + + } + +})(); diff --git a/Tests/groups/create group 1.js b/Tests/groups/create group 1.js index a9bc5e9b..3c52681f 100644 --- a/Tests/groups/create group 1.js +++ b/Tests/groups/create group 1.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sonic', 'assets/sprites/sonic_havok_sanity.png'); - game.loader.load(); + 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 017c4020..d0970c61 100644 --- a/Tests/groups/create group 1.ts +++ b/Tests/groups/create group 1.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sonic', 'assets/sprites/sonic_havok_sanity.png'); - game.loader.load(); + game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png'); + game.load.start(); } diff --git a/Tests/groups/display order.js b/Tests/groups/display order.js index 8c5ee7e4..db0cc529 100644 --- a/Tests/groups/display order.js +++ b/Tests/groups/display order.js @@ -2,10 +2,10 @@ (function () { var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { - game.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png'); - game.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png'); - game.loader.addImageFile('card', 'assets/sprites/mana_card.png'); - game.loader.load(); + 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 f9cb0621..609282d0 100644 --- a/Tests/groups/display order.ts +++ b/Tests/groups/display order.ts @@ -6,11 +6,11 @@ function init() { - game.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png'); - game.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png'); - game.loader.addImageFile('card', 'assets/sprites/mana_card.png'); + 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.loader.load(); + game.load.start(); } diff --git a/Tests/groups/swap children.js b/Tests/groups/swap children.js index ecdf4bf3..ea94dadb 100644 --- a/Tests/groups/swap children.js +++ b/Tests/groups/swap children.js @@ -2,9 +2,9 @@ (function () { var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { - game.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png'); - game.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png'); - game.loader.load(); + 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 4044a0bb..c824f049 100644 --- a/Tests/groups/swap children.ts +++ b/Tests/groups/swap children.ts @@ -6,10 +6,10 @@ function init() { - game.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png'); - game.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png'); + game.load.image('atari1', 'assets/sprites/atari130xe.png'); + game.load.image('atari2', 'assets/sprites/atari800xl.png'); - game.loader.load(); + game.load.start(); } diff --git a/Tests/input/drag sprite 1.js b/Tests/input/drag sprite 1.js index fceb4e57..934ef0a9 100644 --- a/Tests/input/drag sprite 1.js +++ b/Tests/input/drag sprite 1.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sprite', 'assets/sprites/atari130xe.png'); - game.loader.load(); + 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 f9e8ce32..6df65a62 100644 --- a/Tests/input/drag sprite 1.ts +++ b/Tests/input/drag sprite 1.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sprite', 'assets/sprites/atari130xe.png'); - game.loader.load(); + game.load.image('sprite', 'assets/sprites/atari130xe.png'); + game.load.start(); } @@ -31,6 +31,7 @@ function render() { game.input.renderDebugInfo(32, 32); + //game.input.mousePointer.renderDebug(32, 32); sprite.input.renderDebugInfo(300, 32); } diff --git a/Tests/input/drag sprite 2.js b/Tests/input/drag sprite 2.js index 75d6b503..033c487d 100644 --- a/Tests/input/drag sprite 2.js +++ b/Tests/input/drag sprite 2.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sprite', 'assets/sprites/atari800.png'); - game.loader.load(); + 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 8729219e..1b006435 100644 --- a/Tests/input/drag sprite 2.ts +++ b/Tests/input/drag sprite 2.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sprite', 'assets/sprites/atari800.png'); - game.loader.load(); + game.load.image('sprite', 'assets/sprites/atari800.png'); + game.load.start(); } diff --git a/Tests/input/motion lock 2.js b/Tests/input/motion lock 2.js index 73669aeb..025e5181 100644 --- a/Tests/input/motion lock 2.js +++ b/Tests/input/motion lock 2.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sprite', 'assets/sprites/darkwing_crazy.png'); - game.loader.load(); + 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 dc22bad9..bdf10536 100644 --- a/Tests/input/motion lock 2.ts +++ b/Tests/input/motion lock 2.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sprite', 'assets/sprites/darkwing_crazy.png'); - game.loader.load(); + 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 b0d7b52a..44ee232d 100644 --- a/Tests/input/motion lock.js +++ b/Tests/input/motion lock.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sprite', 'assets/sprites/parsec.png'); - game.loader.load(); + 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 3d7c2cce..bd294541 100644 --- a/Tests/input/motion lock.ts +++ b/Tests/input/motion lock.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sprite', 'assets/sprites/parsec.png'); - game.loader.load(); + 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 c8688b12..b3f1083f 100644 --- a/Tests/input/over sprite 1.js +++ b/Tests/input/over sprite 1.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sprite', 'assets/sprites/atari130xe.png'); - game.loader.load(); + 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 5a595df5..efa97ceb 100644 --- a/Tests/input/over sprite 1.ts +++ b/Tests/input/over sprite 1.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sprite', 'assets/sprites/atari130xe.png'); - game.loader.load(); + 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 664c4a4a..52eb22b8 100644 --- a/Tests/input/over sprite 2.js +++ b/Tests/input/over sprite 2.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sprite', 'assets/sprites/shinyball.png'); - game.loader.load(); + 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 25e29ae9..475166ae 100644 --- a/Tests/input/over sprite 2.ts +++ b/Tests/input/over sprite 2.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('sprite', 'assets/sprites/shinyball.png'); - game.loader.load(); + game.load.image('sprite', 'assets/sprites/shinyball.png'); + game.load.start(); } diff --git a/Tests/input/snap 1.js b/Tests/input/snap 1.js index 9e64b8de..068c7529 100644 --- a/Tests/input/snap 1.js +++ b/Tests/input/snap 1.js @@ -3,10 +3,10 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png'); - game.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png'); - game.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png'); - game.loader.load(); + 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 0dc62477..f6773add 100644 --- a/Tests/input/snap 1.ts +++ b/Tests/input/snap 1.ts @@ -7,10 +7,10 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png'); - game.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png'); - game.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png'); - game.loader.load(); + 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 dc45981c..0bbaa601 100644 --- a/Tests/input/touch priority.js +++ b/Tests/input/touch priority.js @@ -3,10 +3,10 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png'); - game.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png'); - game.loader.addImageFile('sonic', 'assets/sprites/sonic_havok_sanity.png'); - game.loader.load(); + 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 6c6d75b3..0284dd21 100644 --- a/Tests/input/touch priority.ts +++ b/Tests/input/touch priority.ts @@ -7,10 +7,10 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png'); - game.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png'); - game.loader.addImageFile('sonic', 'assets/sprites/sonic_havok_sanity.png'); - game.loader.load(); + 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 drag.js b/Tests/input/world drag.js index 72191c9f..138d3588 100644 --- a/Tests/input/world drag.js +++ b/Tests/input/world drag.js @@ -3,9 +3,9 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); function init() { game.world.setSize(1920, 1200, true); - game.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg'); - game.loader.addImageFile('melon', 'assets/sprites/melon.png'); - game.loader.load(); + game.load.image('backdrop', 'assets/pics/remember-me.jpg'); + game.load.image('melon', 'assets/sprites/melon.png'); + game.load.start(); } var test; function create() { diff --git a/Tests/input/world drag.ts b/Tests/input/world drag.ts index 06fdcbcb..10d0ec2c 100644 --- a/Tests/input/world drag.ts +++ b/Tests/input/world drag.ts @@ -8,10 +8,10 @@ game.world.setSize(1920, 1200, true); - game.loader.addImageFile('backdrop', 'assets/pics/remember-me.jpg'); - game.loader.addImageFile('melon', 'assets/sprites/melon.png'); + game.load.image('backdrop', 'assets/pics/remember-me.jpg'); + game.load.image('melon', 'assets/sprites/melon.png'); - game.loader.load(); + game.load.start(); } diff --git a/Tests/mobile/sprite test 1.js b/Tests/mobile/sprite test 1.js index 7462e943..c5d6a7ef 100644 --- a/Tests/mobile/sprite test 1.js +++ b/Tests/mobile/sprite test 1.js @@ -3,10 +3,10 @@ var game = new Phaser.Game(this, 'game', 320, 400, init, create); var emitter; function init() { - game.loader.addImageFile('backdrop1', 'assets/pics/atari_fujilogo.png'); - game.loader.addImageFile('backdrop2', 'assets/pics/acryl_bladerunner.png'); - game.loader.addImageFile('jet', 'assets/sprites/carrot.png'); - game.loader.load(); + 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 33766eca..d57c0e23 100644 --- a/Tests/mobile/sprite test 1.ts +++ b/Tests/mobile/sprite test 1.ts @@ -8,11 +8,11 @@ function init() { - game.loader.addImageFile('backdrop1', 'assets/pics/atari_fujilogo.png'); - game.loader.addImageFile('backdrop2', 'assets/pics/acryl_bladerunner.png'); - game.loader.addImageFile('jet', 'assets/sprites/carrot.png'); + 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.loader.load(); + 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 ae89a8fc..1b7e59f9 100644 --- a/Tests/particles/graphic emitter.js +++ b/Tests/particles/graphic emitter.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); var emitter; function init() { - game.loader.addImageFile('jet', 'assets/sprites/jets.png'); - game.loader.load(); + 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 1f35f41d..b9f0d974 100644 --- a/Tests/particles/graphic emitter.ts +++ b/Tests/particles/graphic emitter.ts @@ -8,9 +8,9 @@ function init() { - game.loader.addImageFile('jet', 'assets/sprites/jets.png'); + game.load.image('jet', 'assets/sprites/jets.png'); - game.loader.load(); + game.load.start(); } diff --git a/Tests/particles/mousetrail.js b/Tests/particles/mousetrail.js index fd7738b0..cf882a31 100644 --- a/Tests/particles/mousetrail.js +++ b/Tests/particles/mousetrail.js @@ -3,9 +3,9 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); var emitter; function init() { - game.loader.addImageFile('jet', 'assets/sprites/particle1.png'); - game.loader.addImageFile('starfield', 'assets/misc/starfield.jpg'); - game.loader.load(); + 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 eae2a213..3369ca86 100644 --- a/Tests/particles/mousetrail.ts +++ b/Tests/particles/mousetrail.ts @@ -8,9 +8,9 @@ function init() { - game.loader.addImageFile('jet', 'assets/sprites/particle1.png'); - game.loader.addImageFile('starfield', 'assets/misc/starfield.jpg'); - game.loader.load(); + 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 f073067a..1ec28b3d 100644 --- a/Tests/particles/multiple streams.js +++ b/Tests/particles/multiple streams.js @@ -8,13 +8,13 @@ var emitter5; var emitter6; function init() { - game.loader.addImageFile('ball1', 'assets/sprites/aqua_ball.png'); - game.loader.addImageFile('ball2', 'assets/sprites/yellow_ball.png'); - game.loader.addImageFile('ball3', 'assets/sprites/red_ball.png'); - game.loader.addImageFile('ball4', 'assets/sprites/purple_ball.png'); - game.loader.addImageFile('ball5', 'assets/sprites/blue_ball.png'); - game.loader.addImageFile('ball6', 'assets/sprites/green_ball.png'); - game.loader.load(); + 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 a2335dd4..d296fdac 100644 --- a/Tests/particles/multiple streams.ts +++ b/Tests/particles/multiple streams.ts @@ -13,14 +13,14 @@ function init() { - game.loader.addImageFile('ball1', 'assets/sprites/aqua_ball.png'); - game.loader.addImageFile('ball2', 'assets/sprites/yellow_ball.png'); - game.loader.addImageFile('ball3', 'assets/sprites/red_ball.png'); - game.loader.addImageFile('ball4', 'assets/sprites/purple_ball.png'); - game.loader.addImageFile('ball5', 'assets/sprites/blue_ball.png'); - game.loader.addImageFile('ball6', 'assets/sprites/green_ball.png'); + 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.loader.load(); + game.load.start(); } diff --git a/Tests/particles/sprite emitter.js b/Tests/particles/sprite emitter.js index c4cf4e8f..b58bb2a7 100644 --- a/Tests/particles/sprite emitter.js +++ b/Tests/particles/sprite emitter.js @@ -27,12 +27,12 @@ var customParticle = (function (_super) { var game = new Phaser.Game(this, 'game', 800, 600, init, create); var emitter; function init() { - game.loader.addImageFile('carrot', 'assets/sprites/carrot.png'); - game.loader.addImageFile('melon', 'assets/sprites/melon.png'); - game.loader.addImageFile('eggplant', 'assets/sprites/eggplant.png'); - game.loader.addImageFile('mushroom', 'assets/sprites/mushroom.png'); - game.loader.addImageFile('pineapple', 'assets/sprites/pineapple.png'); - game.loader.load(); + 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 11b70ed1..f55845d4 100644 --- a/Tests/particles/sprite emitter.ts +++ b/Tests/particles/sprite emitter.ts @@ -25,13 +25,13 @@ class customParticle extends Phaser.Particle { function init() { - game.loader.addImageFile('carrot', 'assets/sprites/carrot.png'); - game.loader.addImageFile('melon', 'assets/sprites/melon.png'); - game.loader.addImageFile('eggplant', 'assets/sprites/eggplant.png'); - game.loader.addImageFile('mushroom', 'assets/sprites/mushroom.png'); - game.loader.addImageFile('pineapple', 'assets/sprites/pineapple.png'); + 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.loader.load(); + game.load.start(); } diff --git a/Tests/particles/when particles collide.js b/Tests/particles/when particles collide.js index e5608c44..09b713e5 100644 --- a/Tests/particles/when particles collide.js +++ b/Tests/particles/when particles collide.js @@ -4,9 +4,9 @@ var leftEmitter; var rightEmitter; function init() { - game.loader.addImageFile('ball1', 'assets/sprites/aqua_ball.png'); - game.loader.addImageFile('ball2', 'assets/sprites/yellow_ball.png'); - game.loader.load(); + 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 5a49f663..224ae63e 100644 --- a/Tests/particles/when particles collide.ts +++ b/Tests/particles/when particles collide.ts @@ -9,10 +9,10 @@ function init() { - game.loader.addImageFile('ball1', 'assets/sprites/aqua_ball.png'); - game.loader.addImageFile('ball2', 'assets/sprites/yellow_ball.png'); + game.load.image('ball1', 'assets/sprites/aqua_ball.png'); + game.load.image('ball2', 'assets/sprites/yellow_ball.png'); - game.loader.load(); + game.load.start(); } diff --git a/Tests/phaser.js b/Tests/phaser.js index 9cf81893..92335948 100644 --- a/Tests/phaser.js +++ b/Tests/phaser.js @@ -2337,7 +2337,7 @@ var Phaser; enumerable: true, configurable: true }); - Loader.prototype.addImageFile = /** + Loader.prototype.image = /** * Add a new image asset loading request with key and url. * @param key {string} Unique asset key of this image file. * @param url {string} URL of image file. @@ -2356,7 +2356,7 @@ var Phaser; this._keys.push(key); } }; - Loader.prototype.addSpriteSheet = /** + Loader.prototype.spritesheet = /** * Add a new sprite sheet loading request. * @param key {string} Unique asset key of the sheet file. * @param url {string} URL of sheet file. @@ -2382,7 +2382,7 @@ var Phaser; this._keys.push(key); } }; - Loader.prototype.addTextureAtlas = /** + Loader.prototype.atlas = /** * Add a new texture atlas loading request. * @param key {string} Unique asset key of the texture atlas file. * @param textureURL {string} The url of the texture atlas image file. @@ -2467,7 +2467,7 @@ var Phaser; } } }; - Loader.prototype.addAudioFile = /** + Loader.prototype.audio = /** * Add a new audio file loading request. * @param key {string} Unique asset key of the audio file. * @param url {string} URL of audio file. @@ -2487,7 +2487,7 @@ var Phaser; this._keys.push(key); } }; - Loader.prototype.addTextFile = /** + Loader.prototype.text = /** * Add a new text file loading request. * @param key {string} Unique asset key of the text file. * @param url {string} URL of text file. @@ -2520,7 +2520,7 @@ var Phaser; this._fileList = { }; }; - Loader.prototype.load = /** + Loader.prototype.start = /** * Load assets. * @param onFileLoadCallback {function} Called when each file loaded successfully. * @param onCompleteCallback {function} Called when all assets completely loaded. @@ -6289,7 +6289,7 @@ var Phaser; this._pointerData[pointer.id].y = pointer.scaledY - this._sprite.y; return true; } else { - this._pointOutHandler(pointer); + this._pointerOutHandler(pointer); return false; } } @@ -6308,7 +6308,7 @@ var Phaser; this._sprite.events.onInputOver.dispatch(this._sprite, pointer); } }; - Input.prototype._pointOutHandler = function (pointer) { + Input.prototype._pointerOutHandler = function (pointer) { this._pointerData[pointer.id].isOver = false; this._pointerData[pointer.id].isOut = true; this._pointerData[pointer.id].timeOut = this.game.time.now; @@ -6319,7 +6319,6 @@ var Phaser; }; Input.prototype._touchedHandler = function (pointer) { if(this._pointerData[pointer.id].isDown == false && this._pointerData[pointer.id].isOver == true) { - //console.log('touchDown on', this._sprite.texture.cacheKey,this._sprite.frameName, this._sprite.frameBounds.width,this._sprite.frameBounds.height); this._pointerData[pointer.id].isDown = true; this._pointerData[pointer.id].isUp = false; this._pointerData[pointer.id].timeDown = this.game.time.now; @@ -6492,8 +6491,8 @@ var Phaser; } else { this._dragPoint.setTo(this._sprite.x - pointer.x, this._sprite.y - pointer.y); } - //pointer.draggedObject = this._sprite; - }; + this.updateDrag(pointer); + }; Input.prototype.stopDrag = /** * Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly. */ @@ -6584,10 +6583,10 @@ var Phaser; this._sprite.texture.context.font = '14px Courier'; this._sprite.texture.context.fillStyle = color; this._sprite.texture.context.fillText('Sprite Input: (' + this._sprite.frameBounds.width + ' x ' + this._sprite.frameBounds.height + ')', x, y); - this._sprite.texture.context.fillText('x: ' + this.pointerX(1).toFixed(1) + ' y: ' + this.pointerY(1).toFixed(1), x, y + 14); - this._sprite.texture.context.fillText('over: ' + this.pointerOver(1) + ' duration: ' + this.overDuration(1).toFixed(0), x, y + 28); - this._sprite.texture.context.fillText('down: ' + this.pointerDown(1) + ' duration: ' + this.downDuration(1).toFixed(0), x, y + 42); - this._sprite.texture.context.fillText('just over: ' + this.justOver(1) + ' just out: ' + this.justOut(1), x, y + 56); + this._sprite.texture.context.fillText('x: ' + this.pointerX().toFixed(1) + ' y: ' + this.pointerY().toFixed(1), x, y + 14); + this._sprite.texture.context.fillText('over: ' + this.pointerOver() + ' duration: ' + this.overDuration().toFixed(0), x, y + 28); + this._sprite.texture.context.fillText('down: ' + this.pointerDown() + ' duration: ' + this.downDuration().toFixed(0), x, y + 42); + this._sprite.texture.context.fillText('just over: ' + this.justOver() + ' just out: ' + this.justOut(), x, y + 56); }; return Input; })(); @@ -10549,6 +10548,9 @@ var Phaser; */ this._context = null; this._game = game; + if(window['PhaserGlobal'] && window['PhaserGlobal'].disableAudio == true) { + return; + } if(game.device.webaudio == true) { if(!!window['AudioContext']) { this._context = new window['AudioContext'](); @@ -10740,6 +10742,8 @@ var Phaser; this.orientation = 0; } } + this.scaleFactor = new Phaser.Vec2(1, 1); + this.aspectRatio = 0; window.addEventListener('orientationchange', function (event) { return _this.checkOrientation(event); }, false); @@ -10801,7 +10805,6 @@ var Phaser; // Back to normal this._game.paused = false; this.incorrectOrientation = false; - this._game.input.reset(); this.refresh(); } } else { @@ -10809,7 +10812,6 @@ var Phaser; // Show orientation screen this._game.paused = true; this.incorrectOrientation = true; - this._game.input.reset(); this.refresh(); } } @@ -10905,32 +10907,43 @@ var Phaser; } else if(this._game.stage.scaleMode == StageScaleMode.SHOW_ALL) { this.setShowAll(); } + this.setSize(); clearInterval(this._check); this._check = null; } }; - StageScaleMode.prototype.setMaximum = function () { - this.width = window.innerWidth; - this.height = window.innerHeight; - this._game.stage.canvas.style.width = this.width + 'px'; - this._game.stage.canvas.style.height = this.height + 'px'; - this._game.input.scaleX = this._game.stage.width / this.width; - this._game.input.scaleY = this._game.stage.height / this.height; - }; - 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); + StageScaleMode.prototype.setSize = function () { if(this.maxWidth && this.width > this.maxWidth) { this.width = this.maxWidth; } if(this.maxHeight && this.height > this.maxHeight) { this.height = this.maxHeight; } + if(this.minWidth && this.width < this.minWidth) { + this.width = this.minWidth; + } + if(this.minHeight && this.height < this.minHeight) { + 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.scaleX = this._game.stage.width / this.width; this._game.input.scaleY = this._game.stage.height / this.height; + 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.width / this._game.stage.width; + //this.scaleFactor.y = this.height / this._game.stage.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); }; StageScaleMode.prototype.setExactFit = function () { if(this.maxWidth && window.innerWidth > this.maxWidth) { @@ -10943,10 +10956,6 @@ var Phaser; } else { this.height = window.innerHeight; } - this._game.stage.canvas.style.width = this.width + 'px'; - this._game.stage.canvas.style.height = this.height + 'px'; - this._game.input.scaleX = this._game.stage.width / this.width; - this._game.input.scaleY = this._game.stage.height / this.height; }; return StageScaleMode; })(); @@ -11201,9 +11210,7 @@ var Phaser; } else if(this._showOnPortrait) { this.game.stage.context.drawImage(this.portraitImage, 0, 0, this.portraitImage.width, this.portraitImage.height, 0, 0, this.game.stage.width, this.game.stage.height); } - //this.game.stage.context.font = '32px Arial'; - //this.game.stage.context.fillText('w: ' + this.game.stage.width + ' h: ' + this.game.stage.height, 32, 32); - }; + }; return OrientationScreen; })(); Phaser.OrientationScreen = OrientationScreen; @@ -11260,7 +11267,7 @@ var Phaser; this.canvas = document.createElement('canvas'); this.canvas.width = width; this.canvas.height = height; - if(document.getElementById(parent)) { + if((parent !== '' || parent !== null) && document.getElementById(parent)) { document.getElementById(parent).appendChild(this.canvas); document.getElementById(parent).style.overflow = 'hidden'; } else { @@ -11275,11 +11282,11 @@ var Phaser; event.preventDefault(); }; this.context = this.canvas.getContext('2d'); - this.offset = this.getOffset(this.canvas); - this.bounds = new Phaser.Rectangle(this.offset.x, this.offset.y, width, height); - this.aspectRatio = width / height; this.scaleMode = Phaser.StageScaleMode.NO_SCALE; this.scale = new Phaser.StageScaleMode(this._game); + this.getOffset(this.canvas); + this.bounds = new Phaser.Rectangle(this.offset.x, this.offset.y, width, height); + this.aspectRatio = width / height; document.addEventListener('visibilitychange', function (event) { return _this.visibilityChange(event); }, false); @@ -11300,9 +11307,7 @@ var Phaser; 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.enterLandscape.add(this.orientationChange, this); - //this.scale.enterPortrait.add(this.orientationChange, this); - }; + }; Stage.prototype.update = /** * Update stage for rendering. This will handle scaling, clearing * and PauseScreen/BootScreen updating and rendering. @@ -11344,31 +11349,7 @@ var Phaser; } } }; - Stage.prototype.enableOrientationCheck = /** - * This method is called when the device orientation changes. - */ - /* - private orientationChange(format: number, landscape: bool, portrait: bool) { - - if (this.scale.forceLandscape && portrait) - { - this._game.paused = true; - this.scale.incorrectOrientation = true; - } - else if (this.scale.forcePortrait && landscape) - { - this._game.paused = true; - this.scale.incorrectOrientation = true; - } - else if ((this.scale.forceLandscape && landscape) || (this.scale.forcePortrait && portrait)) - { - this._game.paused = false; - this.scale.incorrectOrientation = false; - } - - } - */ - function (forceLandscape, forcePortrait, imageKey) { + Stage.prototype.enableOrientationCheck = function (forceLandscape, forcePortrait, imageKey) { if (typeof imageKey === "undefined") { imageKey = ''; } this.scale.forceLandscape = forceLandscape; this.scale.forcePortrait = forcePortrait; @@ -11384,25 +11365,35 @@ var Phaser; } }; Stage.prototype.pauseGame = function () { - this.pauseScreen.onPaused(); + if(this.disablePauseScreen == false && this.pauseScreen) { + this.pauseScreen.onPaused(); + } this.saveCanvasValues(); this._game.paused = true; }; Stage.prototype.resumeGame = function () { - this.pauseScreen.onResume(); + if(this.disablePauseScreen == false && this.pauseScreen) { + this.pauseScreen.onResume(); + } this.restoreCanvasValues(); this._game.paused = false; }; Stage.prototype.getOffset = /** * Get the DOM offset values of the given element */ - function (element) { + function (element, populateOffset) { + if (typeof populateOffset === "undefined") { populateOffset = true; } var box = element.getBoundingClientRect(); var clientTop = element.clientTop || document.body.clientTop || 0; var clientLeft = element.clientLeft || document.body.clientLeft || 0; var scrollTop = window.pageYOffset || element.scrollTop || document.body.scrollTop; var scrollLeft = window.pageXOffset || element.scrollLeft || document.body.scrollLeft; - return new Phaser.Point(box.left + scrollLeft - clientLeft, box.top + scrollTop - clientTop); + if(populateOffset) { + this.offset = new Phaser.Point(box.left + scrollLeft - clientLeft, box.top + scrollTop - clientTop); + return this.offset; + } else { + return new Phaser.Point(box.left + scrollLeft - clientLeft, box.top + scrollTop - clientTop); + } }; Stage.prototype.saveCanvasValues = /** * Save current canvas properties (strokeStyle, lineWidth and fillStyle) for later using. @@ -14220,7 +14211,7 @@ var Phaser; this.button = event.button; } // Fix to stop rogue browser plugins from blocking the visibility state event - if(this.game.paused == true) { + if(this.game.paused == true && this.game.stage.scale.incorrectOrientation == false) { this.game.stage.resumeGame(); return this; } @@ -14243,28 +14234,6 @@ var Phaser; if(this.isMouse == false) { this.game.input.currentPointers++; } - // Build our temporary click stack - /* - var _highestPriority = 0; - var _highestRenderID = 0; - var _highestRenderObject: number = -1; - - for (var i = 0; i < this.game.input.totalTrackedObjects; i++) - { - if (this.game.input.inputObjects[i].input.checkPointerOver(this) && this.game.input.inputObjects[i].renderOrderID > _highestRenderID) - { - _highestRenderID = this.game.input.inputObjects[i].renderOrderID; - _highestRenderObject = i; - } - } - - if (_highestRenderObject !== -1 && this._stateReset == false) - { - this.targetObject = this.game.input.inputObjects[_highestRenderObject]; - this.targetObject.input._touchedHandler(this); - //_highestRenderObject.input._touchedHandler(this); - } - */ if(this.targetObject !== null) { this.targetObject.input._touchedHandler(this); } @@ -14289,49 +14258,7 @@ var Phaser; this._history.shift(); } } - // Iterate through the tracked objects - // Build our temporary click stack - /* - var _highestPriority = 0; - var _highestRenderID = 0; - var _highestRenderObject = null; - - for (var i = 0; i < this.game.input.totalTrackedObjects; i++) - { - if (this.game.input.inputObjects[i].input.enabled) - { - //if (this.game.input.inputObjects[i].input.update(this) && this.game.input.inputObjects[i].input.priorityID > _highestPriority) - if (this.game.input.inputObjects[i].input.update(this) && this.game.input.inputObjects[i].renderOrderID > _highestRenderID) - { - _highestRenderID = this.game.input.inputObjects[i].renderOrderID; - _highestRenderObject = this.game.input.inputObjects[i]; - } - } - } - - if (_highestRenderObject !== null) - { - _highestRenderObject.input._pointerOverHandler(this); - - if (this.isDown && this._stateReset == false) - { - _highestRenderObject.input._touchedHandler(this); - } - - // Now update all objects with the highest priority ID (can be more than 1) - //for (var i = 0; i < this.game.input.totalTrackedObjects; i++) - //{ - // if (this.game.input.inputObjects[i].input.priorityID == _highestPriority) - // { - // if (this.game.input.inputObjects[i].input._touchedHandler(this) == false) - // { - // return; - // } - // } - //} - } - */ - } + } }; Pointer.prototype.move = /** * Called when the Pointer is moved on the touchscreen @@ -14366,7 +14293,7 @@ var Phaser; } } else { // Build our temporary click stack - var _highestRenderID = 0; + var _highestRenderID = -1; var _highestRenderObject = -1; for(var i = 0; i < this.game.input.totalTrackedObjects; i++) { if(this.game.input.inputObjects[i].input.checkPointerOver(this) && this.game.input.inputObjects[i].renderOrderID > _highestRenderID) { @@ -14374,7 +14301,6 @@ var Phaser; _highestRenderObject = i; } } - //console.log('pointer move', _highestRenderID); if(_highestRenderObject !== -1) { //console.log('setting target'); this.targetObject = this.game.input.inputObjects[_highestRenderObject]; @@ -14482,6 +14408,9 @@ var Phaser; this._holdSent = false; this._history.length = 0; this._stateReset = true; + if(this.targetObject) { + this.targetObject.input._releasedHandler(this); + } this.targetObject = null; }; Pointer.prototype.renderDebug = /** @@ -15126,8 +15055,8 @@ var Phaser; } event.preventDefault(); for(var i = 0; i < event.changedTouches.length; i++) { - console.log('touch enter'); - } + //console.log('touch enter'); + } }; Touch.prototype.onTouchLeave = /** * For touch enter and leave its a list of the touch points that have entered or left the target @@ -15141,8 +15070,8 @@ var Phaser; } event.preventDefault(); for(var i = 0; i < event.changedTouches.length; i++) { - console.log('touch leave'); - } + //console.log('touch leave'); + } }; Touch.prototype.onTouchMove = /** * @@ -15534,12 +15463,7 @@ var Phaser; this.pointer10.reset(); } this.currentPointers = 0; - for(var i = 0; i < this.totalTrackedObjects; i++) { - this.inputObjects[i].input.reset(); - } this._game.stage.canvas.style.cursor = "default"; - this.inputObjects.length = 0; - this.totalTrackedObjects = 0; if(hard == true) { this.onDown.dispose(); this.onUp.dispose(); @@ -15549,6 +15473,11 @@ var Phaser; this.onUp = new Phaser.Signal(); this.onTap = new Phaser.Signal(); this.onHold = new Phaser.Signal(); + for(var i = 0; i < this.totalTrackedObjects; i++) { + this.inputObjects[i].input.reset(); + } + this.inputObjects.length = 0; + this.totalTrackedObjects = 0; } }; Object.defineProperty(Input.prototype, "totalInactivePointers", { @@ -15777,7 +15706,7 @@ var Phaser; */ function (x, y, color) { if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } - this._game.stage.context.font = '24px Courier'; + this._game.stage.context.font = '14px Courier'; this._game.stage.context.fillStyle = color; this._game.stage.context.fillText('Input', x, y); this._game.stage.context.fillText('Screen X: ' + this.x + ' Screen Y: ' + this.y, x, y + 14); @@ -16241,7 +16170,7 @@ var Phaser; */ this._step = 0; /** - * Whether loader complete loading or not. + * Whether load complete loading or not. * @type {boolean} */ this._loadComplete = false; @@ -16343,7 +16272,7 @@ var Phaser; this.add = new Phaser.GameObjectFactory(this); this.sound = new Phaser.SoundManager(this); this.cache = new Phaser.Cache(this); - this.loader = new Phaser.Loader(this, this.loadComplete); + this.load = new Phaser.Loader(this, this.loadComplete); this.time = new Phaser.Time(this); this.tweens = new Phaser.TweenManager(this); this.input = new Phaser.Input(this); @@ -16387,7 +16316,7 @@ var Phaser; } }; Game.prototype.loadComplete = /** - * Called when the loader has finished after init was run. + * Called when the load has finished after init was run. */ function () { this._loadComplete = true; @@ -16440,10 +16369,10 @@ var Phaser; */ function () { if(this.onInitCallback !== null) { - this.loader.reset(); + this.load.reset(); this.onInitCallback.call(this.callbackContext); - // Is the loader empty? - if(this.loader.queueSize == 0) { + // Is the load empty? + if(this.load.queueSize == 0) { if(this.onCreateCallback !== null) { this.onCreateCallback.call(this.callbackContext); } @@ -16552,7 +16481,7 @@ var Phaser; this.onDestroyCallback = null; this.cache = null; this.input = null; - this.loader = null; + this.load = null; this.sound = null; this.stage = null; this.time = null; @@ -17090,7 +17019,7 @@ var Phaser; this.camera = game.camera; this.cache = game.cache; this.input = game.input; - this.loader = game.loader; + this.load = game.load; this.math = game.math; this.motion = game.motion; this.sound = game.sound; diff --git a/Tests/physics/aabb 1.js b/Tests/physics/aabb 1.js index 91312c9b..d8fd9fbd 100644 --- a/Tests/physics/aabb 1.js +++ b/Tests/physics/aabb 1.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('atari', 'assets/sprites/atari800xl.png'); - game.loader.load(); + game.load.image('atari', 'assets/sprites/atari800xl.png'); + game.load.start(); } var atari; function create() { diff --git a/Tests/physics/aabb 1.ts b/Tests/physics/aabb 1.ts index 91b9f2f7..0295c21f 100644 --- a/Tests/physics/aabb 1.ts +++ b/Tests/physics/aabb 1.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('atari', 'assets/sprites/atari800xl.png'); - game.loader.load(); + game.load.image('atari', 'assets/sprites/atari800xl.png'); + game.load.start(); } diff --git a/Tests/physics/aabb vs aabb 1.js b/Tests/physics/aabb vs aabb 1.js index 031a360a..01407402 100644 --- a/Tests/physics/aabb vs aabb 1.js +++ b/Tests/physics/aabb vs aabb 1.js @@ -3,9 +3,9 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('atari', 'assets/sprites/atari800xl.png'); - game.loader.addImageFile('card', 'assets/sprites/mana_card.png'); - game.loader.load(); + game.load.image('atari', 'assets/sprites/atari800xl.png'); + game.load.image('card', 'assets/sprites/mana_card.png'); + game.load.start(); } var atari; var card; diff --git a/Tests/physics/aabb vs aabb 1.ts b/Tests/physics/aabb vs aabb 1.ts index 0bd06e86..25e16c23 100644 --- a/Tests/physics/aabb vs aabb 1.ts +++ b/Tests/physics/aabb vs aabb 1.ts @@ -7,9 +7,9 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('atari', 'assets/sprites/atari800xl.png'); - game.loader.addImageFile('card', 'assets/sprites/mana_card.png'); - game.loader.load(); + game.load.image('atari', 'assets/sprites/atari800xl.png'); + game.load.image('card', 'assets/sprites/mana_card.png'); + game.load.start(); } diff --git a/Tests/scrollzones/ballscroller.js b/Tests/scrollzones/ballscroller.js index aa38432f..007a74da 100644 --- a/Tests/scrollzones/ballscroller.js +++ b/Tests/scrollzones/ballscroller.js @@ -3,8 +3,8 @@ (function () { var game = new Phaser.Game(this, 'game', 800, 600, init, create, update); function init() { - game.loader.addImageFile('balls', 'assets/sprites/balls.png'); - game.loader.load(); + 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 705fcfd5..44f4e303 100644 --- a/Tests/scrollzones/ballscroller.ts +++ b/Tests/scrollzones/ballscroller.ts @@ -7,9 +7,9 @@ function init() { - game.loader.addImageFile('balls', 'assets/sprites/balls.png'); + game.load.image('balls', 'assets/sprites/balls.png'); - game.loader.load(); + game.load.start(); } diff --git a/Tests/scrollzones/blasteroids.js b/Tests/scrollzones/blasteroids.js index 9ca845d8..2b431080 100644 --- a/Tests/scrollzones/blasteroids.js +++ b/Tests/scrollzones/blasteroids.js @@ -3,11 +3,11 @@ (function () { var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render); function init() { - game.loader.addImageFile('nashwan', 'assets/sprites/xenon2_ship.png'); - game.loader.addImageFile('starfield', 'assets/misc/starfield.jpg'); - game.loader.addImageFile('jet', 'assets/sprites/particle1.png'); - game.loader.addImageFile('bullet', 'assets/misc/bullet1.png'); - game.loader.load(); + 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 e2e199c8..6f969fef 100644 --- a/Tests/scrollzones/blasteroids.ts +++ b/Tests/scrollzones/blasteroids.ts @@ -7,12 +7,12 @@ function init() { - game.loader.addImageFile('nashwan', 'assets/sprites/xenon2_ship.png'); - game.loader.addImageFile('starfield', 'assets/misc/starfield.jpg'); - game.loader.addImageFile('jet', 'assets/sprites/particle1.png'); - game.loader.addImageFile('bullet', 'assets/misc/bullet1.png'); + 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.loader.load(); + game.load.start(); } diff --git a/Tests/scrollzones/parallax.js b/Tests/scrollzones/parallax.js index 35287e5a..8d4c21fa 100644 --- a/Tests/scrollzones/parallax.js +++ b/Tests/scrollzones/parallax.js @@ -3,8 +3,8 @@ (function () { var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { - game.loader.addImageFile('starray', 'assets/pics/auto_scroll_landscape.png'); - game.loader.load(); + 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 c91b15d8..f50a32fe 100644 --- a/Tests/scrollzones/parallax.ts +++ b/Tests/scrollzones/parallax.ts @@ -7,9 +7,9 @@ function init() { - game.loader.addImageFile('starray', 'assets/pics/auto_scroll_landscape.png'); + game.load.image('starray', 'assets/pics/auto_scroll_landscape.png'); - game.loader.load(); + game.load.start(); } diff --git a/Tests/scrollzones/region demo.js b/Tests/scrollzones/region demo.js index 86f86e7f..a93d8ce8 100644 --- a/Tests/scrollzones/region demo.js +++ b/Tests/scrollzones/region demo.js @@ -3,8 +3,8 @@ (function () { var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { - game.loader.addImageFile('angelDawn', 'assets/pics/game14_angel_dawn.png'); - game.loader.load(); + 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 21fac8e3..0a7e3073 100644 --- a/Tests/scrollzones/region demo.ts +++ b/Tests/scrollzones/region demo.ts @@ -7,9 +7,9 @@ function init() { - game.loader.addImageFile('angelDawn', 'assets/pics/game14_angel_dawn.png'); + game.load.image('angelDawn', 'assets/pics/game14_angel_dawn.png'); - game.loader.load(); + game.load.start(); } diff --git a/Tests/scrollzones/scroll window.js b/Tests/scrollzones/scroll window.js index c106b8c6..dc255014 100644 --- a/Tests/scrollzones/scroll window.js +++ b/Tests/scrollzones/scroll window.js @@ -3,9 +3,9 @@ (function () { var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { - game.loader.addImageFile('dragonsun', 'assets/pics/cougar_dragonsun.png'); - game.loader.addImageFile('overlay', 'assets/pics/scrollframe.png'); - game.loader.load(); + 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 dcf8b968..07863017 100644 --- a/Tests/scrollzones/scroll window.ts +++ b/Tests/scrollzones/scroll window.ts @@ -7,10 +7,10 @@ function init() { - game.loader.addImageFile('dragonsun', 'assets/pics/cougar_dragonsun.png'); - game.loader.addImageFile('overlay', 'assets/pics/scrollframe.png'); + game.load.image('dragonsun', 'assets/pics/cougar_dragonsun.png'); + game.load.image('overlay', 'assets/pics/scrollframe.png'); - game.loader.load(); + game.load.start(); } diff --git a/Tests/scrollzones/simple scrollzone.js b/Tests/scrollzones/simple scrollzone.js index 9f23bd2c..71bb8643 100644 --- a/Tests/scrollzones/simple scrollzone.js +++ b/Tests/scrollzones/simple scrollzone.js @@ -3,8 +3,8 @@ (function () { var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { - game.loader.addImageFile('crystal', 'assets/pics/jim_sachs_time_crystal.png'); - game.loader.load(); + 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 16d445d5..c0fc83a9 100644 --- a/Tests/scrollzones/simple scrollzone.ts +++ b/Tests/scrollzones/simple scrollzone.ts @@ -7,8 +7,8 @@ function init() { - game.loader.addImageFile('crystal', 'assets/pics/jim_sachs_time_crystal.png'); - game.loader.load(); + 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 84c6e6a2..c217d4ce 100644 --- a/Tests/scrollzones/skewed scroller.js +++ b/Tests/scrollzones/skewed scroller.js @@ -3,8 +3,8 @@ (function () { var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { - game.loader.addImageFile('balls', 'assets/sprites/balls.png'); - game.loader.load(); + 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 66d37734..58d37f98 100644 --- a/Tests/scrollzones/skewed scroller.ts +++ b/Tests/scrollzones/skewed scroller.ts @@ -7,8 +7,8 @@ function init() { - game.loader.addImageFile('balls', 'assets/sprites/balls.png'); - game.loader.load(); + game.load.image('balls', 'assets/sprites/balls.png'); + game.load.start(); } diff --git a/Tests/sprites/animation 1.js b/Tests/sprites/animation 1.js index b87914fd..54013aba 100644 --- a/Tests/sprites/animation 1.js +++ b/Tests/sprites/animation 1.js @@ -5,8 +5,8 @@ // 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.loader.addSpriteSheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18); - game.loader.load(); + 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 4660abbd..6ee645fb 100644 --- a/Tests/sprites/animation 1.ts +++ b/Tests/sprites/animation 1.ts @@ -10,8 +10,8 @@ // 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.loader.addSpriteSheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18); - game.loader.load(); + 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 c9bb07a1..582c861c 100644 --- a/Tests/sprites/animation 2.js +++ b/Tests/sprites/animation 2.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addSpriteSheet('monster', 'assets/sprites/metalslug_monster39x40.png', 39, 40); - game.loader.load(); + 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 d41037c5..3eb72b74 100644 --- a/Tests/sprites/animation 2.ts +++ b/Tests/sprites/animation 2.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addSpriteSheet('monster', 'assets/sprites/metalslug_monster39x40.png', 39, 40); - game.loader.load(); + 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 20145d1a..dcd1e6e4 100644 --- a/Tests/sprites/create sprite 1.js +++ b/Tests/sprites/create sprite 1.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('bunny', 'assets/sprites/bunny.png'); - game.loader.load(); + 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 d1725201..73247bc9 100644 --- a/Tests/sprites/create sprite 1.ts +++ b/Tests/sprites/create sprite 1.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('bunny', 'assets/sprites/bunny.png'); - game.loader.load(); + game.load.image('bunny', 'assets/sprites/bunny.png'); + game.load.start(); } diff --git a/Tests/sprites/scale sprite 1.js b/Tests/sprites/scale sprite 1.js index baef3bb0..6ee591eb 100644 --- a/Tests/sprites/scale sprite 1.js +++ b/Tests/sprites/scale sprite 1.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('bunny', 'assets/sprites/bunny.png'); - game.loader.load(); + 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 d5c5c2ed..a5c97347 100644 --- a/Tests/sprites/scale sprite 1.ts +++ b/Tests/sprites/scale sprite 1.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('bunny', 'assets/sprites/bunny.png'); - game.loader.load(); + 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 298b2559..adde1518 100644 --- a/Tests/sprites/scale sprite 2.js +++ b/Tests/sprites/scale sprite 2.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('bunny', 'assets/sprites/bunny.png'); - game.loader.load(); + 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 95a24e60..479b773b 100644 --- a/Tests/sprites/scale sprite 2.ts +++ b/Tests/sprites/scale sprite 2.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('bunny', 'assets/sprites/bunny.png'); - game.loader.load(); + 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 6cfbb5b6..02422ae8 100644 --- a/Tests/sprites/scale sprite 3.js +++ b/Tests/sprites/scale sprite 3.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('bunny', 'assets/sprites/bunny.png'); - game.loader.load(); + 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 f4ee1898..108a4b2a 100644 --- a/Tests/sprites/scale sprite 3.ts +++ b/Tests/sprites/scale sprite 3.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('bunny', 'assets/sprites/bunny.png'); - game.loader.load(); + 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 aadb6a84..703f3a68 100644 --- a/Tests/sprites/scale sprite 4.js +++ b/Tests/sprites/scale sprite 4.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('bunny', 'assets/sprites/bunny.png'); - game.loader.load(); + 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 cd048bab..7de60676 100644 --- a/Tests/sprites/scale sprite 4.ts +++ b/Tests/sprites/scale sprite 4.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('bunny', 'assets/sprites/bunny.png'); - game.loader.load(); + 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 e7dbeaf3..e67ed729 100644 --- a/Tests/sprites/scale sprite 5.js +++ b/Tests/sprites/scale sprite 5.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png'); - game.loader.load(); + 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 0f772dac..66452277 100644 --- a/Tests/sprites/scale sprite 5.ts +++ b/Tests/sprites/scale sprite 5.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png'); - game.loader.load(); + 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 ff8325ff..03fd6d42 100644 --- a/Tests/sprites/sprite origin 1.js +++ b/Tests/sprites/sprite origin 1.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png'); - game.loader.load(); + 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 16a145b0..7d6d1850 100644 --- a/Tests/sprites/sprite origin 1.ts +++ b/Tests/sprites/sprite origin 1.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png'); - game.loader.load(); + 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 dd0f7996..f4303b1c 100644 --- a/Tests/sprites/sprite origin 2.js +++ b/Tests/sprites/sprite origin 2.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png'); - game.loader.load(); + 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 6c3edb82..60094fd5 100644 --- a/Tests/sprites/sprite origin 2.ts +++ b/Tests/sprites/sprite origin 2.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png'); - game.loader.load(); + 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 6a5fad8c..26f34a79 100644 --- a/Tests/sprites/sprite origin 3.js +++ b/Tests/sprites/sprite origin 3.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png'); - game.loader.load(); + 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 fb70a699..fb92c18d 100644 --- a/Tests/sprites/sprite origin 3.ts +++ b/Tests/sprites/sprite origin 3.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png'); - game.loader.load(); + 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 cf9d004b..f7b24b13 100644 --- a/Tests/sprites/sprite origin 4.js +++ b/Tests/sprites/sprite origin 4.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png'); - game.loader.load(); + 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 e178a95a..8f1f3f47 100644 --- a/Tests/sprites/sprite origin 4.ts +++ b/Tests/sprites/sprite origin 4.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png'); - game.loader.load(); + game.load.image('fuji', 'assets/pics/atari_fujilogo.png'); + game.load.start(); } diff --git a/Tests/states/typescript/FakeGame.ts b/Tests/states/typescript/FakeGame.ts index bb74ff75..186598ad 100644 --- a/Tests/states/typescript/FakeGame.ts +++ b/Tests/states/typescript/FakeGame.ts @@ -14,10 +14,10 @@ class FakeGame extends State { public init() { - this.loader.addImageFile('track', '../../assets/games/f1/track.png'); - this.loader.addImageFile('car', '../../assets/games/f1/car1.png'); + this.load.image('track', '../../assets/games/f1/track.png'); + this.load.image('car', '../../assets/games/f1/car1.png'); - this.loader.load(); + this.load.start(); } diff --git a/Tests/states/typescript/MainMenu.ts b/Tests/states/typescript/MainMenu.ts index 9702c1f3..a288b76d 100644 --- a/Tests/states/typescript/MainMenu.ts +++ b/Tests/states/typescript/MainMenu.ts @@ -16,10 +16,10 @@ class MainMenu extends State { public init() { - this.loader.addImageFile('car', '../../assets/pics/supercars_parsec.png'); + this.load.image('car', '../../assets/pics/supercars_parsec.png'); this.loader.addSpriteSheet('monster', '../../assets/sprites/metalslug_monster39x40.png', 39, 40); - this.loader.load(); + this.load.start(); } diff --git a/Tests/tweens/tween loop 1.js b/Tests/tweens/tween loop 1.js index 40086aa8..b05bc89f 100644 --- a/Tests/tweens/tween loop 1.js +++ b/Tests/tweens/tween loop 1.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('swirl', 'assets/pics/color_wheel_swirl.png'); - game.loader.load(); + 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 5dd401fc..af5b72f5 100644 --- a/Tests/tweens/tween loop 1.ts +++ b/Tests/tweens/tween loop 1.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('swirl', 'assets/pics/color_wheel_swirl.png'); - game.loader.load(); + 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 8993cbe7..217eae31 100644 --- a/Tests/tweens/tween loop 2.js +++ b/Tests/tweens/tween loop 2.js @@ -3,8 +3,8 @@ var game = new Phaser.Game(this, 'game', 800, 600, init, create); function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('swirl', 'assets/pics/color_wheel_swirl.png'); - game.loader.load(); + 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 95c44335..e4242fd3 100644 --- a/Tests/tweens/tween loop 2.ts +++ b/Tests/tweens/tween loop 2.ts @@ -7,8 +7,8 @@ function init() { // Using Phasers asset loader we load up a PNG from the assets folder - game.loader.addImageFile('swirl', 'assets/pics/color_wheel_swirl.png'); - game.loader.load(); + 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 3efb98df..a8ef3fb3 100644 --- a/build/phaser.d.ts +++ b/build/phaser.d.ts @@ -1519,7 +1519,7 @@ module Phaser { * @param key {string} Unique asset key of this image file. * @param url {string} URL of image file. */ - public addImageFile(key: string, url: string): void; + public image(key: string, url: string): void; /** * Add a new sprite sheet loading request. * @param key {string} Unique asset key of the sheet file. @@ -1528,7 +1528,7 @@ module Phaser { * @param frameHeight {number} Height of each single frame. * @param frameMax {number} How many frames in this sprite sheet. */ - public addSpriteSheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax?: number): void; + public spritesheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax?: number): void; /** * Add a new texture atlas loading request. * @param key {string} Unique asset key of the texture atlas file. @@ -1537,19 +1537,19 @@ module Phaser { * @param [atlasData] {object} A JSON or XML data object. * @param [format] {number} A value describing the format of the data. */ - public addTextureAtlas(key: string, textureURL: string, atlasURL?: string, atlasData?, format?: number): void; + public atlas(key: string, textureURL: string, atlasURL?: string, atlasData?, format?: number): void; /** * Add a new audio file loading request. * @param key {string} Unique asset key of the audio file. * @param url {string} URL of audio file. */ - public addAudioFile(key: string, url: string): void; + public audio(key: string, url: string): void; /** * Add a new text file loading request. * @param key {string} Unique asset key of the text file. * @param url {string} URL of text file. */ - public addTextFile(key: string, url: string): void; + public text(key: string, url: string): void; /** * Remove loading request of a file. * @param key {string} Key of the file you want to remove. @@ -1564,7 +1564,7 @@ module Phaser { * @param onFileLoadCallback {function} Called when each file loaded successfully. * @param onCompleteCallback {function} Called when all assets completely loaded. */ - public load(onFileLoadCallback?, onCompleteCallback?): void; + public start(onFileLoadCallback?, onCompleteCallback?): void; /** * Load files. Private method ONLY used by loader. */ @@ -3625,7 +3625,7 @@ module Phaser.Components { */ public update(pointer: Pointer): bool; public _pointerOverHandler(pointer: Pointer): void; - public _pointOutHandler(pointer: Pointer): void; + public _pointerOutHandler(pointer: Pointer): void; public consumePointerEvent: bool; public _touchedHandler(pointer: Pointer): bool; public _releasedHandler(pointer: Pointer): void; @@ -8612,7 +8612,7 @@ module Phaser { */ private _step; /** - * Whether loader complete loading or not. + * Whether load complete loading or not. * @type {boolean} */ private _loadComplete; @@ -8684,7 +8684,7 @@ module Phaser { * Reference to the assets loader. * @type {Loader} */ - public loader: Loader; + public load: Loader; /** * Reference to the math helper. * @type {GameMath} @@ -8754,7 +8754,7 @@ module Phaser { private boot(parent, width, height); public setRenderer(type: number): void; /** - * Called when the loader has finished after init was run. + * Called when the load has finished after init was run. */ private loadComplete(); /** @@ -9133,7 +9133,7 @@ module Phaser { * Reference to the assets loader. * @type {Loader} */ - public loader: Loader; + public load: Loader; /** * Reference to the math helper. * @type {GameMath} diff --git a/build/phaser.js b/build/phaser.js index 1258d308..92335948 100644 --- a/build/phaser.js +++ b/build/phaser.js @@ -2337,7 +2337,7 @@ var Phaser; enumerable: true, configurable: true }); - Loader.prototype.addImageFile = /** + Loader.prototype.image = /** * Add a new image asset loading request with key and url. * @param key {string} Unique asset key of this image file. * @param url {string} URL of image file. @@ -2356,7 +2356,7 @@ var Phaser; this._keys.push(key); } }; - Loader.prototype.addSpriteSheet = /** + Loader.prototype.spritesheet = /** * Add a new sprite sheet loading request. * @param key {string} Unique asset key of the sheet file. * @param url {string} URL of sheet file. @@ -2382,7 +2382,7 @@ var Phaser; this._keys.push(key); } }; - Loader.prototype.addTextureAtlas = /** + Loader.prototype.atlas = /** * Add a new texture atlas loading request. * @param key {string} Unique asset key of the texture atlas file. * @param textureURL {string} The url of the texture atlas image file. @@ -2467,7 +2467,7 @@ var Phaser; } } }; - Loader.prototype.addAudioFile = /** + Loader.prototype.audio = /** * Add a new audio file loading request. * @param key {string} Unique asset key of the audio file. * @param url {string} URL of audio file. @@ -2487,7 +2487,7 @@ var Phaser; this._keys.push(key); } }; - Loader.prototype.addTextFile = /** + Loader.prototype.text = /** * Add a new text file loading request. * @param key {string} Unique asset key of the text file. * @param url {string} URL of text file. @@ -2520,7 +2520,7 @@ var Phaser; this._fileList = { }; }; - Loader.prototype.load = /** + Loader.prototype.start = /** * Load assets. * @param onFileLoadCallback {function} Called when each file loaded successfully. * @param onCompleteCallback {function} Called when all assets completely loaded. @@ -6289,7 +6289,7 @@ var Phaser; this._pointerData[pointer.id].y = pointer.scaledY - this._sprite.y; return true; } else { - this._pointOutHandler(pointer); + this._pointerOutHandler(pointer); return false; } } @@ -6308,7 +6308,7 @@ var Phaser; this._sprite.events.onInputOver.dispatch(this._sprite, pointer); } }; - Input.prototype._pointOutHandler = function (pointer) { + Input.prototype._pointerOutHandler = function (pointer) { this._pointerData[pointer.id].isOver = false; this._pointerData[pointer.id].isOut = true; this._pointerData[pointer.id].timeOut = this.game.time.now; @@ -6318,9 +6318,7 @@ var Phaser; this._sprite.events.onInputOut.dispatch(this._sprite, pointer); }; Input.prototype._touchedHandler = function (pointer) { - console.log('touched handler', this._pointerData[pointer.id]); if(this._pointerData[pointer.id].isDown == false && this._pointerData[pointer.id].isOver == true) { - //console.log('touchDown on', this._sprite.texture.cacheKey,this._sprite.frameName, this._sprite.frameBounds.width,this._sprite.frameBounds.height); this._pointerData[pointer.id].isDown = true; this._pointerData[pointer.id].isUp = false; this._pointerData[pointer.id].timeDown = this.game.time.now; @@ -6335,7 +6333,6 @@ var Phaser; return this.consumePointerEvent; }; Input.prototype._releasedHandler = function (pointer) { - console.log('release handler'); // If was previously touched by this Pointer, check if still is if(this._pointerData[pointer.id].isDown && pointer.isUp) { this._pointerData[pointer.id].isDown = false; @@ -6494,8 +6491,8 @@ var Phaser; } else { this._dragPoint.setTo(this._sprite.x - pointer.x, this._sprite.y - pointer.y); } - //pointer.draggedObject = this._sprite; - }; + this.updateDrag(pointer); + }; Input.prototype.stopDrag = /** * Called by Pointer when drag is stopped on this Sprite. Should not usually be called directly. */ @@ -6583,13 +6580,13 @@ var Phaser; */ function (x, y, color) { if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } - this._sprite.texture.context.font = '16px Courier'; + this._sprite.texture.context.font = '14px Courier'; this._sprite.texture.context.fillStyle = color; this._sprite.texture.context.fillText('Sprite Input: (' + this._sprite.frameBounds.width + ' x ' + this._sprite.frameBounds.height + ')', x, y); - this._sprite.texture.context.fillText('x: ' + this.pointerX(1).toFixed(1) + ' y: ' + this.pointerY(1).toFixed(1), x, y + 14); - this._sprite.texture.context.fillText('over: ' + this.pointerOver(1) + ' duration: ' + this.overDuration(1).toFixed(0), x, y + 28); - this._sprite.texture.context.fillText('down: ' + this.pointerDown(1) + ' duration: ' + this.downDuration(1).toFixed(0), x, y + 42); - this._sprite.texture.context.fillText('just over: ' + this.justOver(1) + ' just out: ' + this.justOut(1), x, y + 56); + this._sprite.texture.context.fillText('x: ' + this.pointerX().toFixed(1) + ' y: ' + this.pointerY().toFixed(1), x, y + 14); + this._sprite.texture.context.fillText('over: ' + this.pointerOver() + ' duration: ' + this.overDuration().toFixed(0), x, y + 28); + this._sprite.texture.context.fillText('down: ' + this.pointerDown() + ' duration: ' + this.downDuration().toFixed(0), x, y + 42); + this._sprite.texture.context.fillText('just over: ' + this.justOver() + ' just out: ' + this.justOut(), x, y + 56); }; return Input; })(); @@ -10551,6 +10548,9 @@ var Phaser; */ this._context = null; this._game = game; + if(window['PhaserGlobal'] && window['PhaserGlobal'].disableAudio == true) { + return; + } if(game.device.webaudio == true) { if(!!window['AudioContext']) { this._context = new window['AudioContext'](); @@ -11365,14 +11365,14 @@ var Phaser; } }; Stage.prototype.pauseGame = function () { - if(this.disablePauseScreen == false) { + if(this.disablePauseScreen == false && this.pauseScreen) { this.pauseScreen.onPaused(); } this.saveCanvasValues(); this._game.paused = true; }; Stage.prototype.resumeGame = function () { - if(this.disablePauseScreen == false) { + if(this.disablePauseScreen == false && this.pauseScreen) { this.pauseScreen.onResume(); } this.restoreCanvasValues(); @@ -14234,28 +14234,6 @@ var Phaser; if(this.isMouse == false) { this.game.input.currentPointers++; } - // Build our temporary click stack - /* - var _highestPriority = 0; - var _highestRenderID = 0; - var _highestRenderObject: number = -1; - - for (var i = 0; i < this.game.input.totalTrackedObjects; i++) - { - if (this.game.input.inputObjects[i].input.checkPointerOver(this) && this.game.input.inputObjects[i].renderOrderID > _highestRenderID) - { - _highestRenderID = this.game.input.inputObjects[i].renderOrderID; - _highestRenderObject = i; - } - } - - if (_highestRenderObject !== -1 && this._stateReset == false) - { - this.targetObject = this.game.input.inputObjects[_highestRenderObject]; - this.targetObject.input._touchedHandler(this); - //_highestRenderObject.input._touchedHandler(this); - } - */ if(this.targetObject !== null) { this.targetObject.input._touchedHandler(this); } @@ -14280,49 +14258,7 @@ var Phaser; this._history.shift(); } } - // Iterate through the tracked objects - // Build our temporary click stack - /* - var _highestPriority = 0; - var _highestRenderID = 0; - var _highestRenderObject = null; - - for (var i = 0; i < this.game.input.totalTrackedObjects; i++) - { - if (this.game.input.inputObjects[i].input.enabled) - { - //if (this.game.input.inputObjects[i].input.update(this) && this.game.input.inputObjects[i].input.priorityID > _highestPriority) - if (this.game.input.inputObjects[i].input.update(this) && this.game.input.inputObjects[i].renderOrderID > _highestRenderID) - { - _highestRenderID = this.game.input.inputObjects[i].renderOrderID; - _highestRenderObject = this.game.input.inputObjects[i]; - } - } - } - - if (_highestRenderObject !== null) - { - _highestRenderObject.input._pointerOverHandler(this); - - if (this.isDown && this._stateReset == false) - { - _highestRenderObject.input._touchedHandler(this); - } - - // Now update all objects with the highest priority ID (can be more than 1) - //for (var i = 0; i < this.game.input.totalTrackedObjects; i++) - //{ - // if (this.game.input.inputObjects[i].input.priorityID == _highestPriority) - // { - // if (this.game.input.inputObjects[i].input._touchedHandler(this) == false) - // { - // return; - // } - // } - //} - } - */ - } + } }; Pointer.prototype.move = /** * Called when the Pointer is moved on the touchscreen @@ -14357,7 +14293,7 @@ var Phaser; } } else { // Build our temporary click stack - var _highestRenderID = 0; + var _highestRenderID = -1; var _highestRenderObject = -1; for(var i = 0; i < this.game.input.totalTrackedObjects; i++) { if(this.game.input.inputObjects[i].input.checkPointerOver(this) && this.game.input.inputObjects[i].renderOrderID > _highestRenderID) { @@ -15770,7 +15706,7 @@ var Phaser; */ function (x, y, color) { if (typeof color === "undefined") { color = 'rgb(255,255,255)'; } - this._game.stage.context.font = '24px Courier'; + this._game.stage.context.font = '14px Courier'; this._game.stage.context.fillStyle = color; this._game.stage.context.fillText('Input', x, y); this._game.stage.context.fillText('Screen X: ' + this.x + ' Screen Y: ' + this.y, x, y + 14); @@ -16234,7 +16170,7 @@ var Phaser; */ this._step = 0; /** - * Whether loader complete loading or not. + * Whether load complete loading or not. * @type {boolean} */ this._loadComplete = false; @@ -16336,7 +16272,7 @@ var Phaser; this.add = new Phaser.GameObjectFactory(this); this.sound = new Phaser.SoundManager(this); this.cache = new Phaser.Cache(this); - this.loader = new Phaser.Loader(this, this.loadComplete); + this.load = new Phaser.Loader(this, this.loadComplete); this.time = new Phaser.Time(this); this.tweens = new Phaser.TweenManager(this); this.input = new Phaser.Input(this); @@ -16380,7 +16316,7 @@ var Phaser; } }; Game.prototype.loadComplete = /** - * Called when the loader has finished after init was run. + * Called when the load has finished after init was run. */ function () { this._loadComplete = true; @@ -16433,10 +16369,10 @@ var Phaser; */ function () { if(this.onInitCallback !== null) { - this.loader.reset(); + this.load.reset(); this.onInitCallback.call(this.callbackContext); - // Is the loader empty? - if(this.loader.queueSize == 0) { + // Is the load empty? + if(this.load.queueSize == 0) { if(this.onCreateCallback !== null) { this.onCreateCallback.call(this.callbackContext); } @@ -16545,7 +16481,7 @@ var Phaser; this.onDestroyCallback = null; this.cache = null; this.input = null; - this.loader = null; + this.load = null; this.sound = null; this.stage = null; this.time = null; @@ -17083,7 +17019,7 @@ var Phaser; this.camera = game.camera; this.cache = game.cache; this.input = game.input; - this.loader = game.loader; + this.load = game.load; this.math = game.math; this.motion = game.motion; this.sound = game.sound;