mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 22:52:14 +00:00
Animation.updateFrame will now call setSizeToFrame
on the Game Object, which will adjust the Game Objects width
and height
properties to match the frame size. Fix #3473
This commit is contained in:
parent
96507beda1
commit
51d29b818d
2 changed files with 40 additions and 15 deletions
|
@ -49,6 +49,8 @@ being passed to the simulation. The default value is 1 to remain consistent with
|
||||||
* The ComputedSize Component now has `setSize` and `setDisplaySize` methods. This component is used for Game Objects that have a non-texture based size.
|
* The ComputedSize Component now has `setSize` and `setDisplaySize` methods. This component is used for Game Objects that have a non-texture based size.
|
||||||
* The GamepadManager now extends EventEmitter directly, just like the KeyboardManager does.
|
* The GamepadManager now extends EventEmitter directly, just like the KeyboardManager does.
|
||||||
* The Gamepad Axis threshold has been increased from 0.05 to 0.1.
|
* The Gamepad Axis threshold has been increased from 0.05 to 0.1.
|
||||||
|
* Animation.updateFrame will now call `setSizeToFrame` on the Game Object, which will adjust the Game Objects `width` and `height` properties to match the frame size. Fix #3473 (thanks @wtravO @jp-gc)
|
||||||
|
* Animation.updateFrame now supports animation frames with custom pivot points and injects these into the Game Object origin.
|
||||||
|
|
||||||
Also, my thanks to the following for helping with the Phaser 3 Examples and Docs, either by reporting errors, fixing them or helping author the docs: @gabegordon @melissaelopez @samid737 @nbs @tgrajewski @pagesrichie @hexus @mbrickn @erd0s @icbat @Matthew-Herman
|
Also, my thanks to the following for helping with the Phaser 3 Examples and Docs, either by reporting errors, fixing them or helping author the docs: @gabegordon @melissaelopez @samid737 @nbs @tgrajewski @pagesrichie @hexus @mbrickn @erd0s @icbat @Matthew-Herman
|
||||||
|
|
||||||
|
|
|
@ -513,13 +513,7 @@ var Animation = new Class({
|
||||||
{
|
{
|
||||||
this.stop();
|
this.stop();
|
||||||
|
|
||||||
var sprite = this.parent;
|
this.setCurrentFrame(this.currentAnim.frames[0]);
|
||||||
var frame = this.currentAnim.frames[0];
|
|
||||||
|
|
||||||
this.currentFrame = frame;
|
|
||||||
|
|
||||||
sprite.texture = frame.frame.texture;
|
|
||||||
sprite.frame = frame.frame;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -733,6 +727,40 @@ var Animation = new Class({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the given Animation Frame as being the current frame
|
||||||
|
* and applies it to the parent Game Object, adjusting its size and origin as needed.
|
||||||
|
*
|
||||||
|
* @method Phaser.GameObjects.Components.Animation#setCurrentFrame
|
||||||
|
* @since 3.4.0
|
||||||
|
*
|
||||||
|
* @param {Phaser.Animations.AnimationFrame} animationFrame - The Animation Frame to set as being current.
|
||||||
|
*
|
||||||
|
* @return {Phaser.GameObjects.GameObject} The Game Object this Animation Component belongs to.
|
||||||
|
*/
|
||||||
|
setCurrentFrame: function (animationFrame)
|
||||||
|
{
|
||||||
|
var gameObject = this.parent;
|
||||||
|
|
||||||
|
this.currentFrame = animationFrame;
|
||||||
|
|
||||||
|
gameObject.texture = animationFrame.frame.texture;
|
||||||
|
gameObject.frame = animationFrame.frame;
|
||||||
|
|
||||||
|
gameObject.setSizeToFrame();
|
||||||
|
|
||||||
|
if (animationFrame.frame.customPivot)
|
||||||
|
{
|
||||||
|
gameObject.setOrigin(animationFrame.frame.pivotX, animationFrame.frame.pivotY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gameObject.updateDisplayOrigin();
|
||||||
|
}
|
||||||
|
|
||||||
|
return gameObject;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [description]
|
* [description]
|
||||||
*
|
*
|
||||||
|
@ -743,18 +771,13 @@ var Animation = new Class({
|
||||||
*/
|
*/
|
||||||
updateFrame: function (animationFrame)
|
updateFrame: function (animationFrame)
|
||||||
{
|
{
|
||||||
var sprite = this.parent;
|
var gameObject = this.setCurrentFrame(animationFrame);
|
||||||
|
|
||||||
this.currentFrame = animationFrame;
|
|
||||||
|
|
||||||
sprite.texture = animationFrame.frame.texture;
|
|
||||||
sprite.frame = animationFrame.frame;
|
|
||||||
|
|
||||||
if (this.isPlaying)
|
if (this.isPlaying)
|
||||||
{
|
{
|
||||||
if (animationFrame.setAlpha)
|
if (animationFrame.setAlpha)
|
||||||
{
|
{
|
||||||
sprite.alpha = animationFrame.alpha;
|
gameObject.alpha = animationFrame.alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
var anim = this.currentAnim;
|
var anim = this.currentAnim;
|
||||||
|
@ -766,7 +789,7 @@ var Animation = new Class({
|
||||||
|
|
||||||
if (animationFrame.onUpdate)
|
if (animationFrame.onUpdate)
|
||||||
{
|
{
|
||||||
animationFrame.onUpdate(sprite, animationFrame);
|
animationFrame.onUpdate(gameObject, animationFrame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue