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.
This commit is contained in:
photonstorm 2014-02-08 13:45:18 +00:00
parent 243820c973
commit e8b432f518
3 changed files with 16 additions and 2 deletions

View file

@ -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.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). * 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'. * 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: Bug Fixes:
@ -101,6 +102,7 @@ Bug Fixes:
* Fixed TypeScript defs on lines 1741-1748 (thanks wombatbuddy) * 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. * 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. * 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 You can view the Change Log for all previous versions at https://github.com/photonstorm/phaser/changelog.md

View file

@ -330,6 +330,19 @@ Phaser.Camera.prototype = {
this.view.width = width; this.view.width = width;
this.view.height = height; 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;
} }
}; };

View file

@ -178,8 +178,7 @@ Phaser.World.prototype.setBounds = function (x, y, width, height) {
*/ */
Phaser.World.prototype.destroy = function () { Phaser.World.prototype.destroy = function () {
this.camera.x = 0; this.camera.reset();
this.camera.y = 0;
this.game.input.reset(true); this.game.input.reset(true);