77*
88* Phaser - http://phaser.io
99*
10- * v2.0.3 "Allorallen" - Built: Tue Apr 01 2014 03:01:02
10+ * v2.0.3 "Allorallen" - Built: Tue Apr 01 2014 16:12:36
1111*
1212* By Richard Davey http://www.photonstorm.com @photonstorm
1313*
@@ -3880,7 +3880,7 @@ Phaser.StateManager.prototype = {
38803880 */
38813881 remove: function (key) {
38823882
3883- if (this.current == key)
3883+ if (this.current === key)
38843884 {
38853885 this.callbackContext = null;
38863886
@@ -3931,6 +3931,31 @@ Phaser.StateManager.prototype = {
39313931
39323932 },
39333933
3934+ /**
3935+ * Restarts the current State. State.shutDown will be called (if it exists) before the State is restarted.
3936+ *
3937+ * @method Phaser.StateManager#restart
3938+ * @param {boolean} [clearWorld=true] - Clear everything in the world? This clears the World display list fully (but not the Stage, so if you've added your own objects to the Stage they will need managing directly)
3939+ * @param {boolean} [clearCache=false] - Clear the Game.Cache? This purges out all loaded assets. The default is false and you must have clearWorld=true if you want to clearCache as well.
3940+ * @param {...*} parameter - Additional parameters that will be passed to the State.init function if it has one.
3941+ */
3942+ restart: function (clearWorld, clearCache) {
3943+
3944+ if (typeof clearWorld === "undefined") { clearWorld = true; }
3945+ if (typeof clearCache === "undefined") { clearCache = false; }
3946+
3947+ // Place the state in the queue. It will be started the next time the game loop starts.
3948+ this._pendingState = this.current;
3949+ this._clearWorld = clearWorld;
3950+ this._clearCache = clearCache;
3951+
3952+ if (arguments.length > 3)
3953+ {
3954+ this._args = Array.prototype.splice.call(arguments, 3);
3955+ }
3956+
3957+ },
3958+
39343959 /**
39353960 * Used by onInit and onShutdown when those functions don't exist on the state
39363961 * @method Phaser.StateManager#dummy
@@ -9117,6 +9142,7 @@ Phaser.Game.prototype = {
91179142 this.tweens.update();
91189143 this.sound.update();
91199144 this.input.update();
9145+ // this.state.update();
91209146 this.physics.update();
91219147 this.particles.update();
91229148 this.plugins.update();
@@ -10410,7 +10436,8 @@ Phaser.Key.prototype = {
1041010436 },
1041110437
1041210438 /**
10413- * Resets the state of this Key.
10439+ * Resets the state of this Key. This sets isDown to false, isUp to true, resets the time to be the current time and clears any callbacks
10440+ * associated with the onDown and onUp events and nulls the onHoldCallback if set.
1041410441 *
1041510442 * @method Phaser.Key#reset
1041610443 */
@@ -10421,6 +10448,11 @@ Phaser.Key.prototype = {
1042110448 this.timeUp = this.game.time.now;
1042210449 this.duration = this.game.time.now - this.timeDown;
1042310450
10451+ this.onDown.removeAll();
10452+ this.onUp.removeAll();
10453+ this.onHoldCallback = null;
10454+ this.onHoldContext = null;
10455+
1042410456 },
1042510457
1042610458 /**
@@ -33141,6 +33173,7 @@ Phaser.Sound.prototype = {
3314133173
3314233174 /**
3314333175 * Stop playing this sound.
33176+ *
3314433177 * @method Phaser.Sound#stop
3314533178 */
3314633179 stop: function () {
@@ -33176,6 +33209,38 @@ Phaser.Sound.prototype = {
3317633209 this.currentMarker = '';
3317733210 this.onStop.dispatch(this, prevMarker);
3317833211
33212+ },
33213+
33214+ /**
33215+ * Destroys this sound and all associated events and removes it from the SoundManager.
33216+ *
33217+ * @method Phaser.Sound#destroy
33218+ * @param {boolean} [remove=true] - If true this Sound is automatically removed from the SoundManager.
33219+ */
33220+ destroy: function (remove) {
33221+
33222+ if (typeof remove === 'undefined') { remove = true; }
33223+
33224+ this.stop();
33225+
33226+ if (remove)
33227+ {
33228+ this.game.sound.remove(this);
33229+ }
33230+
33231+ this.markers = {};
33232+ this.context = null;
33233+ this._buffer = null;
33234+ this.externalNode = null;
33235+ this.onDecoded.dispose();
33236+ this.onPlay.dispose();
33237+ this.onPause.dispose();
33238+ this.onResume.dispose();
33239+ this.onLoop.dispose();
33240+ this.onStop.dispose();
33241+ this.onMute.dispose();
33242+ this.onMarkerComplete.dispose();
33243+
3317933244 }
3318033245
3318133246};
@@ -33347,7 +33412,6 @@ Phaser.SoundManager = function (game) {
3334733412 /**
3334833413 * @property {array} _sounds - An array containing all the sounds
3334933414 * @private
33350- * @default The empty array.
3335133415 */
3335233416 this._sounds = [];
3335333417
@@ -33654,8 +33718,61 @@ Phaser.SoundManager.prototype = {
3365433718
3365533719 },
3365633720
33721+ /**
33722+ * Removes a Sound from the SoundManager. The removed Sound is destroyed before removal.
33723+ *
33724+ * @method Phaser.SoundManager#remove
33725+ * @param {Phaser.Sound} sound - The sound object to remove.
33726+ * @return {boolean} True if the sound was removed successfully, otherwise false.
33727+ */
33728+ remove: function (sound) {
33729+
33730+ var i = this._sounds.length;
33731+
33732+ while (i--)
33733+ {
33734+ if (this._sounds[i] === sound)
33735+ {
33736+ this._sounds[i].destroy(false);
33737+ this._sounds.splice(i, 1);
33738+ return true;
33739+ }
33740+ }
33741+
33742+ return false;
33743+
33744+ },
33745+
33746+ /**
33747+ * Removes all Sounds from the SoundManager that have an asset key matching the given value.
33748+ * The removed Sounds are destroyed before removal.
33749+ *
33750+ * @method Phaser.SoundManager#removeByKey
33751+ * @param {string} key - The key to match when removing sound objects.
33752+ * @return {number} The number of matching sound objects that were removed.
33753+ */
33754+ removeByKey: function (key) {
33755+
33756+ var i = this._sounds.length;
33757+ var removed = 0;
33758+
33759+ while (i--)
33760+ {
33761+ if (this._sounds[i].key === key)
33762+ {
33763+ this._sounds[i].destroy(false);
33764+ this._sounds.splice(i, 1);
33765+ removed++;
33766+ }
33767+ }
33768+
33769+ return removed;
33770+
33771+ },
33772+
3365733773 /**
3365833774 * Adds a new Sound into the SoundManager and starts it playing.
33775+ *
3365933776 * @method Phaser.SoundManager#play
3366033777 * @param {string} key - Asset key for the sound.
3366133778 * @param {number} [volume=1] - Default value for the volume.
@@ -37196,7 +37313,7 @@ Phaser.Physics.Arcade.Body.prototype = {
3719637313 /**
3719737314 * Internal method.
3719837315 *
37199- * @method Phaser.Physics.Arcade#updateBounds
37316+ * @method Phaser.Physics.Arcade.Body #updateBounds
3720037317 * @protected
3720137318 */
3720237319 updateBounds: function () {
@@ -37222,7 +37339,7 @@ Phaser.Physics.Arcade.Body.prototype = {
3722237339 /**
3722337340 * Internal method.
3722437341 *
37225- * @method Phaser.Physics.Arcade#preUpdate
37342+ * @method Phaser.Physics.Arcade.Body #preUpdate
3722637343 * @protected
3722737344 */
3722837345 preUpdate: function () {
@@ -37297,7 +37414,7 @@ Phaser.Physics.Arcade.Body.prototype = {
3729737414 /**
3729837415 * Internal method.
3729937416 *
37300- * @method Phaser.Physics.Arcade#postUpdate
37417+ * @method Phaser.Physics.Arcade.Body #postUpdate
3730137418 * @protected
3730237419 */
3730337420 postUpdate: function () {
@@ -37370,7 +37487,7 @@ Phaser.Physics.Arcade.Body.prototype = {
3737037487 /**
3737137488 * Removes this bodies reference to its parent sprite, freeing it up for gc.
3737237489 *
37373- * @method Phaser.Physics.Arcade#destroy
37490+ * @method Phaser.Physics.Arcade.Body #destroy
3737437491 */
3737537492 destroy: function () {
3737637493
@@ -37381,7 +37498,7 @@ Phaser.Physics.Arcade.Body.prototype = {
3738137498 /**
3738237499 * Internal method.
3738337500 *
37384- * @method Phaser.Physics.Arcade#checkWorldBounds
37501+ * @method Phaser.Physics.Arcade.Body #checkWorldBounds
3738537502 * @protected
3738637503 */
3738737504 checkWorldBounds: function () {
@@ -37419,7 +37536,7 @@ Phaser.Physics.Arcade.Body.prototype = {
3741937536 * So it could be smaller or larger than the parent Sprite. You can also control the x and y offset, which
3742037537 * is the position of the Body relative to the top-left of the Sprite.
3742137538 *
37422- * @method Phaser.Physics.Arcade#setSize
37539+ * @method Phaser.Physics.Arcade.Body #setSize
3742337540 * @param {number} width - The width of the Body.
3742437541 * @param {number} height - The height of the Body.
3742537542 * @param {number} offsetX - The X offset of the Body from the Sprite position.
@@ -37445,9 +37562,9 @@ Phaser.Physics.Arcade.Body.prototype = {
3744537562 /**
3744637563 * Resets all Body values (velocity, acceleration, rotation, etc)
3744737564 *
37448- * @method Phaser.Physics.Arcade#reset
37565+ * @method Phaser.Physics.Arcade.Body #reset
3744937566 * @param {number} x - The new x position of the Body.
37450- * @param {number} y - The new x position of the Body.
37567+ * @param {number} y - The new y position of the Body.
3745137568 */
3745237569 reset: function (x, y) {
3745337570
@@ -37473,6 +37590,20 @@ Phaser.Physics.Arcade.Body.prototype = {
3747337590
3747437591 },
3747537592
37593+ /**
37594+ * Tests if a world point lies within this Body.
37595+ *
37596+ * @method Phaser.Physics.Arcade.Body#hitTest
37597+ * @param {number} x - The world x coordinate to test.
37598+ * @param {number} y - The world y coordinate to test.
37599+ * @return {boolean} True if the given coordinates are inside this Body, otherwise false.
37600+ */
37601+ hitTest: function (x, y) {
37602+
37603+ return Phaser.Rectangle.contains(this, x, y);
37604+
37605+ },
37606+
3747637607 /**
3747737608 * Returns true if the bottom of this Body is in contact with either the world bounds or a tile.
3747837609 *
@@ -39750,18 +39881,77 @@ Phaser.Tilemap.prototype = {
3975039881
3975139882 },
3975239883
39884+ /**
39885+ * Removes the tile located at the given coordinates and updates the collision data.
39886+ *
39887+ * @method Phaser.Tilemap#removeTile
39888+ * @param {number} x - X position to place the tile (given in tile units, not pixels)
39889+ * @param {number} y - Y position to place the tile (given in tile units, not pixels)
39890+ * @param {number|string|Phaser.TilemapLayer} [layer] - The layer to modify.
39891+ * @return {Phaser.Tile} The Tile object that was removed from this map.
39892+ */
39893+ removeTile: function (x, y, layer) {
39894+
39895+ layer = this.getLayer(layer);
39896+
39897+ if (x >= 0 && x < this.layers[layer].width && y >= 0 && y < this.layers[layer].height)
39898+ {
39899+ if (this.hasTile(x, y, layer))
39900+ {
39901+ var tile = this.layers[layer].data[y][x];
39902+
39903+ this.layers[layer].data[y][x] = null;
39904+
39905+ this.layers[layer].dirty = true;
39906+
39907+ this.calculateFaces(layer);
39908+
39909+ return tile;
39910+ }
39911+ }
39912+
39913+ },
39914+
39915+ /**
39916+ * Removes the tile located at the given coordinates and updates the collision data. The coordinates are given in pixel values.
39917+ *
39918+ * @method Phaser.Tilemap#removeTileWorldXY
39919+ * @param {number} x - X position to insert the tile (given in pixels)
39920+ * @param {number} y - Y position to insert the tile (given in pixels)
39921+ * @param {number} tileWidth - The width of the tile in pixels.
39922+ * @param {number} tileHeight - The height of the tile in pixels.
39923+ * @param {number|string|Phaser.TilemapLayer} [layer] - The layer to modify.
39924+ * @return {Phaser.Tile} The Tile object that was removed from this map.
39925+ */
39926+ removeTileWorldXY: function (x, y, tileWidth, tileHeight, layer) {
39927+
39928+ layer = this.getLayer(layer);
39929+
39930+ x = this.game.math.snapToFloor(x, tileWidth) / tileWidth;
39931+ y = this.game.math.snapToFloor(y, tileHeight) / tileHeight;
39932+
39933+ return this.removeTile(x, y, layer);
39934+
39935+ },
39936+
3975339937 /**
3975439938 * Puts a tile of the given index value at the coordinate specified.
39939+ * If you pass `null` as the tile it will pass your call over to Tilemap.removeTile instead.
3975539940 *
3975639941 * @method Phaser.Tilemap#putTile
39757- * @param {Phaser.Tile|number} tile - The index of this tile to set or a Phaser.Tile object.
39942+ * @param {Phaser.Tile|number|null } tile - The index of this tile to set or a Phaser.Tile object. If null the tile is removed from the map .
3975839943 * @param {number} x - X position to place the tile (given in tile units, not pixels)
3975939944 * @param {number} y - Y position to place the tile (given in tile units, not pixels)
3976039945 * @param {number|string|Phaser.TilemapLayer} [layer] - The layer to modify.
3976139946 * @return {Phaser.Tile} The Tile object that was created or added to this map.
3976239947 */
3976339948 putTile: function (tile, x, y, layer) {
3976439949
39950+ if (tile === null)
39951+ {
39952+ return this.removeTile(x, y, layer);
39953+ }
39954+
3976539955 layer = this.getLayer(layer);
3976639956
3976739957 if (x >= 0 && x < this.layers[layer].width && y >= 0 && y < this.layers[layer].height)
@@ -39825,6 +40015,7 @@ Phaser.Tilemap.prototype = {
3982540015 * @param {number} tileWidth - The width of the tile in pixels.
3982640016 * @param {number} tileHeight - The height of the tile in pixels.
3982740017 * @param {number|string|Phaser.TilemapLayer} [layer] - The layer to modify.
40018+ * @return {Phaser.Tile} The Tile object that was created or added to this map.
3982840019 */
3982940020 putTileWorldXY: function (tile, x, y, tileWidth, tileHeight, layer) {
3983040021
@@ -39833,7 +40024,7 @@ Phaser.Tilemap.prototype = {
3983340024 x = this.game.math.snapToFloor(x, tileWidth) / tileWidth;
3983440025 y = this.game.math.snapToFloor(y, tileHeight) / tileHeight;
3983540026
39836- this.putTile(tile, x, y, layer);
40027+ return this.putTile(tile, x, y, layer);
3983740028
3983840029 },
3983940030
0 commit comments