From e8b432f5182d35edbc3b052cce8d21fc4895033a Mon Sep 17 00:00:00 2001 From: photonstorm Date: Sat, 8 Feb 2014 13:45:18 +0000 Subject: [PATCH] Fixed bug where changing State would cause the camera to not reset if it was following an object. World.reset now calls Camera.reset which sends the camera back to 0,0 and un-follows any object it may have been tracking. --- README.md | 2 ++ src/core/Camera.js | 13 +++++++++++++ src/core/World.js | 3 +-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 24d9d041..4d496847 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 8d9baa0e..d87d65ba 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 601ec6f6..943d1f99 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);