mirror of
https://github.com/wassname/phaser.git
synced 2026-09-12 12:40:47 +08:00
+10
-2
@@ -15,8 +15,8 @@ Phaser.Animation.Parser = {
|
||||
* @method spriteSheet
|
||||
* @param {Phaser.Game} game A reference to the currently running game.
|
||||
* @param {String} key The Game.Cache asset key of the Sprite Sheet image.
|
||||
* @param {Number} frameWidth The fixed width of each frame of the animation.
|
||||
* @param {Number} frameHeight The fixed height of each frame of the animation.
|
||||
* @param {Number} frameWidth The fixed width of each frame of the animation. If negative, indicates how many columns there are.
|
||||
* @param {Number} frameHeight The fixed height of each frame of the animation. If negative, indicates how many rows there are.
|
||||
* @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".
|
||||
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
|
||||
*/
|
||||
@@ -32,6 +32,14 @@ Phaser.Animation.Parser = {
|
||||
|
||||
var width = img.width;
|
||||
var height = img.height;
|
||||
if (frameWidth <= 0)
|
||||
{
|
||||
frameWidth = Math.floor(-width/Math.min(-1, frameWidth));
|
||||
}
|
||||
if (frameHeight <= 0)
|
||||
{
|
||||
frameHeight = Math.floor(-height/Math.min(-1, frameHeight));
|
||||
}
|
||||
var row = Math.round(width / frameWidth);
|
||||
var column = Math.round(height / frameHeight);
|
||||
var total = row * column;
|
||||
|
||||
@@ -259,13 +259,6 @@ Phaser.StateManager.prototype = {
|
||||
{
|
||||
// console.log('Loader queue empty');
|
||||
this.game.loadComplete();
|
||||
|
||||
if (this.onCreateCallback)
|
||||
{
|
||||
this.onCreateCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
this._created = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -278,14 +271,6 @@ Phaser.StateManager.prototype = {
|
||||
{
|
||||
// console.log('Preload callback not found');
|
||||
// No init? Then there was nothing to load either
|
||||
if (this.onCreateCallback)
|
||||
{
|
||||
// console.log('Create callback found');
|
||||
this.onCreateCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
this._created = true;
|
||||
|
||||
this.game.loadComplete();
|
||||
}
|
||||
|
||||
@@ -383,9 +368,9 @@ Phaser.StateManager.prototype = {
|
||||
if (this._created == false && this.onCreateCallback)
|
||||
{
|
||||
// console.log('Create callback found');
|
||||
this._created = true;
|
||||
this.onCreateCallback.call(this.callbackContext);
|
||||
}
|
||||
this._created = true;
|
||||
|
||||
},
|
||||
|
||||
@@ -455,4 +440,4 @@ Phaser.StateManager.prototype = {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -80,6 +80,9 @@ Phaser.BitmapText.prototype.update = function() {
|
||||
this._cache.dirty = true;
|
||||
}
|
||||
|
||||
this.pivot.x = this.anchor.x*this.width;
|
||||
this.pivot.y = this.anchor.y*this.height;
|
||||
|
||||
}
|
||||
|
||||
Object.defineProperty(Phaser.BitmapText.prototype, 'angle', {
|
||||
|
||||
+36
-12
@@ -244,8 +244,8 @@ Phaser.Math = {
|
||||
|
||||
if (typeof radians === "undefined") { radians = true; }
|
||||
|
||||
var rd = (radians) ? GameMath.PI : 180;
|
||||
return this.wrap(angle, rd, -rd);
|
||||
var rd = (radians) ? Math.PI : 180;
|
||||
return this.wrap(angle, -rd, rd);
|
||||
|
||||
},
|
||||
|
||||
@@ -257,7 +257,7 @@ Phaser.Math = {
|
||||
|
||||
if (typeof radians === "undefined") { radians = true; }
|
||||
|
||||
var rd = (radians) ? GameMath.PI : 180;
|
||||
var rd = (radians) ? Math.PI : 180;
|
||||
a1 = this.normalizeAngle(a1, radians);
|
||||
a2 = this.normalizeAngle(a2, radians);
|
||||
|
||||
@@ -387,15 +387,39 @@ Phaser.Math = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.
|
||||
* <p>Values must be positive integers, and are passed through Math.abs</p>
|
||||
*
|
||||
* @param value The value to add the amount to
|
||||
* @param amount The amount to add to the value
|
||||
* @param max The maximum the value is allowed to be
|
||||
* @return The wrapped value
|
||||
*/
|
||||
/**
|
||||
* Ensures that the value always stays between min and max, by wrapping the value around.
|
||||
* <p>max should be larger than min, or the function will return 0</p>
|
||||
*
|
||||
* @param value The value to wrap
|
||||
* @param min The minimum the value is allowed to be
|
||||
* @param max The maximum the value is allowed to be
|
||||
* @return The wrapped value
|
||||
*/
|
||||
wrap: function (value, min, max) {
|
||||
|
||||
var range = max - min;
|
||||
if (range <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
var result = (value - min) % range;
|
||||
if (result < 0)
|
||||
{
|
||||
result += range;
|
||||
}
|
||||
return result + min;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds value to amount and ensures that the result always stays between 0 and max, by wrapping the value around.
|
||||
* <p>Values must be positive integers, and are passed through Math.abs</p>
|
||||
*
|
||||
* @param value The value to add the amount to
|
||||
* @param amount The amount to add to the value
|
||||
* @param max The maximum the value is allowed to be
|
||||
* @return The wrapped value
|
||||
*/
|
||||
wrapValue: function (value, amount, max) {
|
||||
|
||||
var diff;
|
||||
|
||||
@@ -135,7 +135,7 @@ PIXI.BitmapText.prototype.updateText = function()
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
this.width = maxLineWidth * scale;
|
||||
this.height = (pos.y + data.lineHeight) * scale;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user