diff --git a/README.md b/README.md index 24d9d0413..4d4968470 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ Updates: * Game.add.renderTexture now has the addToCache parameter. If set the texture will be stored in Game.Cache and can be retrieved with Cache.getTexture(key). * Game.add.bitmapData now has the addToCache parameter. If set the texture will be stored in Game.Cache and can be retrieved with Cache.getBitmapData(key). * The InputManager now sets the canvas style cursor to 'inherit' instead of 'default'. +* World.reset now calls Camera.reset which sends the camera back to 0,0 and un-follows any object it may have been tracking. Bug Fixes: @@ -101,6 +102,7 @@ Bug Fixes: * Fixed TypeScript defs on lines 1741-1748 (thanks wombatbuddy) * Previously if you used Sprite.crop() it would crop all Sprites using the same base image. It now takes a local copy of the texture data and crops just that. * Tilemap had the wrong @method signatures so most were missing from the docs. +* Fixed bug where changing State would cause the camera to not reset if it was following an object. You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md diff --git a/src/core/Camera.js b/src/core/Camera.js index 8d9baa0e4..d87d65ba8 100644 --- a/src/core/Camera.js +++ b/src/core/Camera.js @@ -330,6 +330,19 @@ Phaser.Camera.prototype = { this.view.width = width; this.view.height = height; + }, + + /** + * Resets the camera back to 0,0 and un-follows any object it may have been tracking. + * + * @method Phaser.Camera#reset + */ + reset: function () { + + this.target = null; + this.camera.x = 0; + this.camera.y = 0; + } }; diff --git a/src/core/World.js b/src/core/World.js index 601ec6f6b..943d1f99c 100644 --- a/src/core/World.js +++ b/src/core/World.js @@ -178,8 +178,7 @@ Phaser.World.prototype.setBounds = function (x, y, width, height) { */ Phaser.World.prototype.destroy = function () { - this.camera.x = 0; - this.camera.y = 0; + this.camera.reset(); this.game.input.reset(true);