Skip to content

Commit 96365a3

Browse files
committed
The StateManager is now responsible for clearing down input, timers, tweens, physics, camera and the World display list.
Removed the use of Int16Array from all Game Objects, swapped for standard Array. Phaser now runs on Android 2.x again (fix phaserjs#590)
1 parent 5d40365 commit 96365a3

12 files changed

Lines changed: 57 additions & 29 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ Bug Fixes
7676
* ArcadePhysics.separate doesn't pass over to seperateX/Y if overlapOnly is true (fix #604)
7777
* ArcadePhysics.collideSpriteVsSprite checks if both objects have bodies before processing.
7878
* Debug.spriteBounds will now take the position of the camera into consideration when rendering the bounds (fix #603)
79-
* InputHandler.dragFromCenter will now work regardless of the anchor point of the Sprite.
79+
* InputHandler.dragFromCenter will now work regardless of the anchor point of the Sprite (fix #600)
8080

8181

82-
Updated:
82+
Updated
8383

8484
* Updated Device.isConsoleOpen as it no longer works in Chrome. Revised code and documentation accordingly (fix #593)
8585
* Removed State.destroy empty method and replaced with State.shutdown, as that is what the StateManager expects (fix #586)
@@ -96,14 +96,17 @@ Updated:
9696
* ArcadePhysics.Body has reverted to the 1.1.3 method of preUpdate, so you can now position sprites with x/y, drag them, etc, regardless of the Body.moves flag (issue #606)
9797
* ArcadePhysics.World now has setBounds and setBoundsToWorld methods, which are called automatically on world resizing.
9898
* ArcadePhysics.Body no longer sets the offset to match the anchor.
99+
* The StateManager is now responsible for clearing down input, timers, tweens, physics, camera and the World display list.
100+
* Removed the use of Int16Array from all Game Objects, swapped for standard Array. Phaser now runs on Android 2.x again (fix #590)
99101

100102

101-
New Features:
103+
New Features
102104

103105
* Device.getUserMedia boolean added, useful if you need access to the webcam or microphone.
104106
* Math.removeRandom allows you to remove (and return) a random object from an array.
105107
* ArcadePhysics.World now has a checkCollision object which can be used to toggle collision against the 4 walls of its bounds.
106108
* Sprite.events.onEnterBounds added. This is dispatched if the Sprite leaves the bounds but then returns. The opposite of onOutOfBounds.
109+
* Timer.removeAll will remove and clear down all events, but keeps the Timer running.
107110

108111

109112

src/core/Group.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ Phaser.Group = function (game, parent, name, addToStage, enableBody, physicsBody
133133
* 7 = fixed to camera (0 = no, 1 = yes)
134134
* 8 = cursor index
135135
* 9 = sort order
136-
* @property {Int16Array} _cache
136+
* @property {Array} _cache
137137
* @private
138138
*/
139-
this._cache = new Int16Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 0]);
139+
this._cache = [ 0, 0, 0, 0, 1, 0, 1, 0, 0, 0 ];
140140

141141
};
142142

src/core/StateManager.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,20 +277,28 @@ Phaser.StateManager.prototype = {
277277
// Already got a state running?
278278
if (this.current)
279279
{
280+
console.log('state preUpdate current');
281+
280282
this.onShutDownCallback.call(this.callbackContext, this.game);
281-
}
282283

283-
if (this._clearWorld)
284-
{
285284
this.game.tweens.removeAll();
286285

287-
this.game.world.shutdown();
286+
this.game.camera.reset();
287+
288+
this.game.input.reset(true);
288289

289290
this.game.physics.clear();
290291

291-
if (this._clearCache === true)
292+
this.game.time.removeAll();
293+
294+
if (this._clearWorld)
292295
{
293-
this.game.cache.destroy();
296+
this.game.world.shutdown();
297+
298+
if (this._clearCache === true)
299+
{
300+
this.game.cache.destroy();
301+
}
294302
}
295303
}
296304

src/core/World.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,11 @@ Phaser.World.prototype.setBounds = function (x, y, width, height) {
9494

9595
/**
9696
* Destroyer of worlds.
97+
*
9798
* @method Phaser.World#shutdown
9899
*/
99100
Phaser.World.prototype.shutdown = function () {
100101

101-
this.camera.reset();
102-
103-
this.game.input.reset(true);
104-
105102
// World is a Group, so run a soft destruction on this and all children.
106103
this.destroy(true, true);
107104

src/gameobjects/BitmapText.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ Phaser.BitmapText = function (game, x, y, font, text, size) {
123123
* 5 = outOfBoundsFired (0 = no, 1 = yes)
124124
* 6 = exists (0 = no, 1 = yes)
125125
* 7 = fixed to camera (0 = no, 1 = yes)
126-
* @property {Int16Array} _cache
126+
* @property {Array} _cache
127127
* @private
128128
*/
129-
this._cache = new Int16Array([0, 0, 0, 0, 1, 0, 1, 0]);
129+
this._cache = [0, 0, 0, 0, 1, 0, 1, 0];
130130

131131
};
132132

src/gameobjects/Graphics.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ Phaser.Graphics = function (game, x, y) {
7171
* 5 = outOfBoundsFired (0 = no, 1 = yes)
7272
* 6 = exists (0 = no, 1 = yes)
7373
* 7 = fixed to camera (0 = no, 1 = yes)
74-
* @property {Int16Array} _cache
74+
* @property {Array} _cache
7575
* @private
7676
*/
77-
this._cache = new Int16Array([0, 0, 0, 0, 1, 0, 1, 0]);
77+
this._cache = [ 0, 0, 0, 0, 1, 0, 1, 0 ];
7878

7979
};
8080

src/gameobjects/Image.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ Phaser.Image = function (game, x, y, key, frame) {
115115
* 5 = outOfBoundsFired (0 = no, 1 = yes)
116116
* 6 = exists (0 = no, 1 = yes)
117117
* 7 = fixed to camera (0 = no, 1 = yes)
118-
* @property {Int16Array} _cache
118+
* @property {Array} _cache
119119
* @private
120120
*/
121-
this._cache = new Int16Array([0, 0, 0, 0, 1, 0, 1, 0]);
121+
this._cache = [ 0, 0, 0, 0, 1, 0, 1, 0 ];
122122

123123
};
124124

src/gameobjects/Sprite.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ Phaser.Sprite = function (game, x, y, key, frame) {
165165
* 5 = outOfBoundsFired (0 = no, 1 = yes)
166166
* 6 = exists (0 = no, 1 = yes)
167167
* 7 = fixed to camera (0 = no, 1 = yes)
168-
* @property {Int16Array} _cache
168+
* @property {Array} _cache
169169
* @private
170170
*/
171-
this._cache = new Int16Array([0, 0, 0, 0, 1, 0, 1, 0]);
171+
this._cache = [ 0, 0, 0, 0, 1, 0, 1, 0 ];
172172

173173
/**
174174
* @property {Phaser.Rectangle} _bounds - Internal cache var.

src/gameobjects/Text.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ Phaser.Text = function (game, x, y, text, style) {
128128
* 5 = outOfBoundsFired (0 = no, 1 = yes)
129129
* 6 = exists (0 = no, 1 = yes)
130130
* 7 = fixed to camera (0 = no, 1 = yes)
131-
* @property {Int16Array} _cache
131+
* @property {Array} _cache
132132
* @private
133133
*/
134-
this._cache = new Int16Array([0, 0, 0, 0, 1, 0, 1, 0]);
134+
this._cache = [ 0, 0, 0, 0, 1, 0, 1, 0 ];
135135

136136
};
137137

src/gameobjects/TileSprite.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ Phaser.TileSprite = function (game, x, y, width, height, key, frame) {
126126
* 5 = outOfBoundsFired (0 = no, 1 = yes)
127127
* 6 = exists (0 = no, 1 = yes)
128128
* 7 = fixed to camera (0 = no, 1 = yes)
129-
* @property {Int16Array} _cache
129+
* @property {Array} _cache
130130
* @private
131131
*/
132-
this._cache = new Int16Array([0, 0, 0, 0, 1, 0, 1, 0]);
132+
this._cache = [ 0, 0, 0, 0, 1, 0, 1, 0 ];
133133

134134
};
135135

0 commit comments

Comments
 (0)