mirror of
https://github.com/wassname/phaser.git
synced 2026-09-09 11:28:47 +08:00
Sorted out the bounds for when sprites are in trimmed texture atlases to stop the physics checks going insane. Also bundled in Advanced Physics lib, although not hooked up yet.
This commit is contained in:
@@ -41,8 +41,8 @@ Phaser.Animation.prototype = {
|
||||
*/
|
||||
play: function (frameRate, loop) {
|
||||
|
||||
if (typeof frameRate === "undefined") { frameRate = null; }
|
||||
if (typeof loop === "undefined") { loop = null; }
|
||||
frameRate = frameRate || null;
|
||||
loop = loop || null;
|
||||
|
||||
if (frameRate !== null)
|
||||
{
|
||||
@@ -113,6 +113,7 @@ Phaser.Animation.prototype = {
|
||||
{
|
||||
this._frameIndex = 0;
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
// this._parent.events.onAnimationLoop.dispatch(this._parent, this);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -177,19 +177,24 @@ Phaser.AnimationManager.prototype = {
|
||||
|
||||
/**
|
||||
* Update animation and parent sprite's bounds.
|
||||
* Returns true if a new frame has been set, otherwise false.
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
if (this.updateIfVisible && this._parent.visible == false)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.currentAnim && this.currentAnim.update() == true)
|
||||
{
|
||||
this.currentFrame = this.currentAnim.currentFrame;
|
||||
this._parent.currentFrame = this.currentFrame;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -256,6 +261,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
|
||||
{
|
||||
this.currentFrame = this._frameData.getFrame(value);
|
||||
this._frameIndex = value;
|
||||
this._parent.currentFrame = this.currentFrame;
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
}
|
||||
|
||||
@@ -282,6 +288,7 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
|
||||
{
|
||||
this.currentFrame = this._frameData.getFrameByName(value);
|
||||
this._frameIndex = this.currentFrame.index;
|
||||
this._parent.currentFrame = this.currentFrame;
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
}
|
||||
else
|
||||
|
||||
+20
-1
@@ -14,6 +14,10 @@ Phaser.Animation.Frame = function (x, y, width, height, name, uuid) {
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.sourceSizeW = width;
|
||||
this.sourceSizeH = height;
|
||||
this.centerX = Math.floor(width / 2);
|
||||
this.centerY = Math.floor(height / 2);
|
||||
this.name = name;
|
||||
this.uuid = uuid;
|
||||
this.distance = Phaser.Math.distance(0, 0, width, height);
|
||||
@@ -51,6 +55,18 @@ Phaser.Animation.Frame.prototype = {
|
||||
*/
|
||||
height: 0,
|
||||
|
||||
/**
|
||||
* center X position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
centerX: 0,
|
||||
|
||||
/**
|
||||
* center Y position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
centerY: 0,
|
||||
|
||||
/**
|
||||
* The distance from the top left to the bottom-right of this Frame.
|
||||
* @type {number}
|
||||
@@ -136,11 +152,14 @@ Phaser.Animation.Frame.prototype = {
|
||||
|
||||
this.trimmed = trimmed;
|
||||
|
||||
if (trimmed) {
|
||||
if (trimmed)
|
||||
{
|
||||
this.width = actualWidth;
|
||||
this.height = actualHeight;
|
||||
this.sourceSizeW = actualWidth;
|
||||
this.sourceSizeH = actualHeight;
|
||||
this.centerX = Math.floor(actualWidth / 2);
|
||||
this.centerY = Math.floor(actualHeight / 2);
|
||||
this.spriteSourceSizeX = destX;
|
||||
this.spriteSourceSizeY = destY;
|
||||
this.spriteSourceSizeW = destWidth;
|
||||
|
||||
Reference in New Issue
Block a user