Skip to content

Commit 6b9484a

Browse files
committed
Merge pull request phaserjs#60 from TheJare/master
Fix bug in StateManager...
2 parents f66e632 + 557160c commit 6b9484a

8 files changed

Lines changed: 61 additions & 54 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
Phaser OSX.sublime-project
44
Phaser OSX.sublime-workspace
55
Phaser.sublime-project
6-
Phaser.sublime-workspace
6+
Phaser.sublime-workspace
7+
node_modules

build/phaser.js

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Phaser - http://www.phaser.io
33
*
4-
* v1.0.5 - Built at: Fri, 20 Sep 2013 12:59:22 +0000
4+
* v1.0.5 - Built at: Fri, 20 Sep 2013 21:16:39 +0000
55
*
66
* @author Richard Davey http://www.photonstorm.com @photonstorm
77
*
@@ -7864,13 +7864,6 @@ Phaser.StateManager.prototype = {
78647864
{
78657865
// console.log('Loader queue empty');
78667866
this.game.loadComplete();
7867-
7868-
if (this.onCreateCallback)
7869-
{
7870-
this.onCreateCallback.call(this.callbackContext);
7871-
}
7872-
7873-
this._created = true;
78747867
}
78757868
else
78767869
{
@@ -7883,14 +7876,6 @@ Phaser.StateManager.prototype = {
78837876
{
78847877
// console.log('Preload callback not found');
78857878
// No init? Then there was nothing to load either
7886-
if (this.onCreateCallback)
7887-
{
7888-
// console.log('Create callback found');
7889-
this.onCreateCallback.call(this.callbackContext);
7890-
}
7891-
7892-
this._created = true;
7893-
78947879
this.game.loadComplete();
78957880
}
78967881

@@ -7988,9 +7973,9 @@ Phaser.StateManager.prototype = {
79887973
if (this._created == false && this.onCreateCallback)
79897974
{
79907975
// console.log('Create callback found');
7991-
this._created = true;
79927976
this.onCreateCallback.call(this.callbackContext);
79937977
}
7978+
this._created = true;
79947979

79957980
},
79967981

@@ -8061,6 +8046,7 @@ Phaser.StateManager.prototype = {
80618046
}
80628047

80638048
};
8049+
80648050
Phaser.LinkedList = function () {
80658051

80668052
this.next = null;
@@ -21681,12 +21667,12 @@ Phaser.Animation.FrameData.prototype = {
2168121667
if (useNumericIndex)
2168221668
{
2168321669
// The actual frame
21684-
output.push(this.getFrame(input[i]));
21670+
output.push(this.getFrame(frames[i]));
2168521671
}
2168621672
else
2168721673
{
2168821674
// The actual frame
21689-
output.push(this.getFrameByName(input[i]));
21675+
output.push(this.getFrameByName(frames[i]));
2169021676
}
2169121677
}
2169221678
}
@@ -21726,7 +21712,7 @@ Phaser.Animation.FrameData.prototype = {
2172621712
// Does the frames array contain names or indexes?
2172721713
if (useNumericIndex)
2172821714
{
21729-
output.push(frames[i].index);
21715+
output.push(frames[i]);
2173021716
}
2173121717
else
2173221718
{

build/phaser.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/animation/Parser.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Phaser.Animation.Parser = {
1515
* @method spriteSheet
1616
* @param {Phaser.Game} game A reference to the currently running game.
1717
* @param {String} key The Game.Cache asset key of the Sprite Sheet image.
18-
* @param {Number} frameWidth The fixed width of each frame of the animation.
19-
* @param {Number} frameHeight The fixed height of each frame of the animation.
18+
* @param {Number} frameWidth The fixed width of each frame of the animation. If negative, indicates how many columns there are.
19+
* @param {Number} frameHeight The fixed height of each frame of the animation. If negative, indicates how many rows there are.
2020
* @param {Number} [frameMax=-1] The total number of animation frames to extact from the Sprite Sheet. The default value of -1 means "extract all frames".
2121
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
2222
*/
@@ -32,6 +32,14 @@ Phaser.Animation.Parser = {
3232

3333
var width = img.width;
3434
var height = img.height;
35+
if (frameWidth <= 0)
36+
{
37+
frameWidth = Math.floor(-width/Math.min(-1, frameWidth));
38+
}
39+
if (frameHeight <= 0)
40+
{
41+
frameHeight = Math.floor(-height/Math.min(-1, frameHeight));
42+
}
3543
var row = Math.round(width / frameWidth);
3644
var column = Math.round(height / frameHeight);
3745
var total = row * column;

src/core/StateManager.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,6 @@ Phaser.StateManager.prototype = {
259259
{
260260
// console.log('Loader queue empty');
261261
this.game.loadComplete();
262-
263-
if (this.onCreateCallback)
264-
{
265-
this.onCreateCallback.call(this.callbackContext);
266-
}
267-
268-
this._created = true;
269262
}
270263
else
271264
{
@@ -278,14 +271,6 @@ Phaser.StateManager.prototype = {
278271
{
279272
// console.log('Preload callback not found');
280273
// No init? Then there was nothing to load either
281-
if (this.onCreateCallback)
282-
{
283-
// console.log('Create callback found');
284-
this.onCreateCallback.call(this.callbackContext);
285-
}
286-
287-
this._created = true;
288-
289274
this.game.loadComplete();
290275
}
291276

@@ -383,9 +368,9 @@ Phaser.StateManager.prototype = {
383368
if (this._created == false && this.onCreateCallback)
384369
{
385370
// console.log('Create callback found');
386-
this._created = true;
387371
this.onCreateCallback.call(this.callbackContext);
388372
}
373+
this._created = true;
389374

390375
},
391376

@@ -455,4 +440,4 @@ Phaser.StateManager.prototype = {
455440

456441
}
457442

458-
};
443+
};

src/gameobjects/BitmapText.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ Phaser.BitmapText.prototype.update = function() {
8080
this._cache.dirty = true;
8181
}
8282

83+
this.pivot.x = this.anchor.x*this.width;
84+
this.pivot.y = this.anchor.y*this.height;
85+
8386
}
8487

8588
Object.defineProperty(Phaser.BitmapText.prototype, 'angle', {

src/math/Math.js

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ Phaser.Math = {
244244

245245
if (typeof radians === "undefined") { radians = true; }
246246

247-
var rd = (radians) ? GameMath.PI : 180;
248-
return this.wrap(angle, rd, -rd);
247+
var rd = (radians) ? Math.PI : 180;
248+
return this.wrap(angle, -rd, rd);
249249

250250
},
251251

@@ -257,7 +257,7 @@ Phaser.Math = {
257257

258258
if (typeof radians === "undefined") { radians = true; }
259259

260-
var rd = (radians) ? GameMath.PI : 180;
260+
var rd = (radians) ? Math.PI : 180;
261261
a1 = this.normalizeAngle(a1, radians);
262262
a2 = this.normalizeAngle(a2, radians);
263263

@@ -387,15 +387,39 @@ Phaser.Math = {
387387

388388
},
389389

390-
/**
391-
* Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.
392-
* <p>Values must be positive integers, and are passed through Math.abs</p>
393-
*
394-
* @param value The value to add the amount to
395-
* @param amount The amount to add to the value
396-
* @param max The maximum the value is allowed to be
397-
* @return The wrapped value
398-
*/
390+
/**
391+
* Ensures that the value always stays between min and max, by wrapping the value around.
392+
* <p>max should be larger than min, or the function will return 0</p>
393+
*
394+
* @param value The value to wrap
395+
* @param min The minimum the value is allowed to be
396+
* @param max The maximum the value is allowed to be
397+
* @return The wrapped value
398+
*/
399+
wrap: function (value, min, max) {
400+
401+
var range = max - min;
402+
if (range <= 0)
403+
{
404+
return 0;
405+
}
406+
var result = (value - min) % range;
407+
if (result < 0)
408+
{
409+
result += range;
410+
}
411+
return result + min;
412+
},
413+
414+
/**
415+
* Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.
416+
* <p>Values must be positive integers, and are passed through Math.abs</p>
417+
*
418+
* @param value The value to add the amount to
419+
* @param amount The amount to add to the value
420+
* @param max The maximum the value is allowed to be
421+
* @return The wrapped value
422+
*/
399423
wrapValue: function (value, amount, max) {
400424

401425
var diff;

src/pixi/text/BitmapText.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ PIXI.BitmapText.prototype.updateText = function()
135135
this.addChild(c);
136136
}
137137

138-
this.width = pos.x * scale;
138+
this.width = maxLineWidth * scale;
139139
this.height = (pos.y + data.lineHeight) * scale;
140140
};
141141

0 commit comments

Comments
 (0)