mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 06:30:38 +00:00
Add animation support to TileSprite.
This commit is contained in:
parent
de036b999f
commit
66fcac346e
1 changed files with 58 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
|||
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
||||
*/
|
||||
|
||||
var AnimationState = require('../../animations/AnimationState');
|
||||
var CanvasPool = require('../../display/canvas/CanvasPool');
|
||||
var Class = require('../../utils/Class');
|
||||
var Components = require('../components');
|
||||
|
@ -260,6 +261,19 @@ var TileSprite = new Class({
|
|||
*/
|
||||
this.fillPattern = null;
|
||||
|
||||
/**
|
||||
* The Animation State component of this TileSprite.
|
||||
*
|
||||
* This component provides features to apply animations to this TileSprite.
|
||||
* It is responsible for playing, loading, queuing animations for later playback,
|
||||
* mixing between animations and setting the current animation frame to this Sprite.
|
||||
*
|
||||
* @name Phaser.GameObjects.TileSprite#anims
|
||||
* @type {Phaser.Animations.AnimationState}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.anims = new AnimationState(this);
|
||||
|
||||
this.setTexture(textureKey, frameKey);
|
||||
this.setPosition(x, y);
|
||||
this.setSize(width, height);
|
||||
|
@ -268,6 +282,33 @@ var TileSprite = new Class({
|
|||
this.initPostPipeline(true);
|
||||
},
|
||||
|
||||
// Overrides Game Object method
|
||||
addedToScene: function ()
|
||||
{
|
||||
this.scene.sys.updateList.add(this);
|
||||
},
|
||||
|
||||
// Overrides Game Object method
|
||||
removedFromScene: function ()
|
||||
{
|
||||
this.scene.sys.updateList.remove(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update this TileSprite's animations.
|
||||
*
|
||||
* @method Phaser.GameObjects.TileSprite#preUpdate
|
||||
* @protected
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} time - The current timestamp.
|
||||
* @param {number} delta - The delta time, in ms, elapsed since the last frame.
|
||||
*/
|
||||
preUpdate: function (time, delta)
|
||||
{
|
||||
this.anims.update(time, delta);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the frame this Game Object will use to render with.
|
||||
*
|
||||
|
@ -302,6 +343,18 @@ var TileSprite = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* No-op method for compatibility with Animation.
|
||||
*
|
||||
* @method Phaser.GameObjects.TileSprite#setSizeToFrame
|
||||
* @since 3.90.0
|
||||
* @return {this} This Tile Sprite instance.
|
||||
*/
|
||||
setSizeToFrame: function ()
|
||||
{
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}.
|
||||
*
|
||||
|
@ -379,7 +432,7 @@ var TileSprite = new Class({
|
|||
*/
|
||||
updateTileTexture: function ()
|
||||
{
|
||||
if (!this.dirty || !this.renderer || this.renderer.gl)
|
||||
if (!this.renderer || this.renderer.gl)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -519,6 +572,10 @@ var TileSprite = new Class({
|
|||
this.displayFrame = null;
|
||||
|
||||
this.renderer = null;
|
||||
|
||||
this.anims.destroy();
|
||||
|
||||
this.anims = undefined;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue