AnimationParser.spriteSheet wasn't taking the margin or spacing into account when calculating the numbers of sprites per row/column, nor was it allowing for extra power-of-two padding at the end (fix #482, thanks yig)

AnimationManager.add documentation said that 'frames' could be null, but the code couldn't handle this so it defaults to an empty array if none given (thanks yig)
Also updated TypeScript definitions and StateManager.add docs.
This commit is contained in:
photonstorm 2014-02-26 01:32:38 +00:00
parent 29fcfc515d
commit 1aea08d0f7
5 changed files with 2329 additions and 1691 deletions

View file

@ -165,6 +165,8 @@ Bug Fixes:
* Fullscreen mode now uses window.outerWidth/Height when using EXACT_FIT as the scale mode, which fixes input coordinate errors (fixes #232)
* Fullscreen mode now works in Internet Explorer and uses the new fullscreen non-prefix call.
* Fixed TilemapParser - would spit out a tileset warning if margin/spacing were set (fix #485, thanks Cybolic)
* AnimationParser.spriteSheet wasn't taking the margin or spacing into account when calculating the numbers of sprites per row/column, nor was it allowing for extra power-of-two padding at the end (fix #482, thanks yig)
* AnimationManager.add documentation said that 'frames' could be null, but the code couldn't handle this so it defaults to an empty array if none given (thanks yig)
TO DO:

4000
build/phaser.d.ts vendored

File diff suppressed because it is too large Load diff

View file

@ -101,6 +101,7 @@ Phaser.AnimationManager.prototype = {
return;
}
frames = frames || [];
frameRate = frameRate || 60;
if (typeof loop === 'undefined') { loop = false; }

View file

@ -47,8 +47,8 @@ Phaser.AnimationParser = {
frameHeight = Math.floor(-height / Math.min(-1, frameHeight));
}
var row = Math.round(width / frameWidth);
var column = Math.round(height / frameHeight);
var row = Math.floor((width - margin) / (frameWidth + spacing));
var column = Math.floor((height - margin) / (frameHeight + spacing));
var total = row * column;
if (frameMax !== -1)
@ -83,7 +83,7 @@ Phaser.AnimationParser = {
x += frameWidth + spacing;
if (x === width)
if (x + frameWidth > width)
{
x = margin;
y += frameHeight + spacing;

View file

@ -152,11 +152,14 @@ Phaser.StateManager.prototype = {
},
/**
* Add a new State.
* Adds a new State into the StateManager. You must give each State a unique key by which you'll identify it.
* The State can be either a Phaser.State object (or an object that extends it), a plain JavaScript object or a function.
* If a function is given a new state object will be created by calling it.
*
* @method Phaser.StateManager#add
* @param key {string} - A unique key you use to reference this state, i.e. "MainMenu", "Level1".
* @param state {State} - The state you want to switch to.
* @param autoStart {boolean} - Start the state immediately after creating it? (default true)
* @param {string} key - A unique key you use to reference this state, i.e. "MainMenu", "Level1".
* @param {Phaser.State|object|function} state - The state you want to switch to.
* @param {boolean} [autoStart=false] - If true the State will be started immediately after adding it.
*/
add: function (key, state, autoStart) {