2018-01-16 13:04:35 +00:00
|
|
|
var Class = require('../utils/Class');
|
2017-10-13 10:56:52 +00:00
|
|
|
|
|
|
|
// Phaser.Animations.AnimationFrame
|
|
|
|
|
|
|
|
var AnimationFrame = new Class({
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
2018-01-21 13:01:38 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @class AnimationFrame
|
|
|
|
* @memberOf Phaser.Animations.AnimationFrame
|
|
|
|
* @constructor
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {undefined} textureKey - [description]
|
|
|
|
* @param {undefined} textureFrame - [description]
|
|
|
|
* @param {undefined} index - [description]
|
|
|
|
* @param {undefined} frame - [description]
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
function AnimationFrame (textureKey, textureFrame, index, frame)
|
|
|
|
{
|
|
|
|
// The keys into the Texture Manager of the texture + frame this uses
|
2018-01-21 13:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {string} textureKey
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
this.textureKey = textureKey;
|
2018-01-21 13:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {Phaser.Textures.Frame} textureFrame
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
this.textureFrame = textureFrame;
|
|
|
|
|
|
|
|
// The index of this frame within the Animation.frames array
|
2018-01-21 13:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {integer} index
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
this.index = index;
|
|
|
|
|
|
|
|
// Texture Frame
|
2018-01-21 13:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {Phaser.Textures.Frame} frame
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
this.frame = frame;
|
|
|
|
|
|
|
|
// Read-only
|
2018-01-21 13:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {boolean} isFirst
|
|
|
|
* @default false
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
this.isFirst = false;
|
|
|
|
|
|
|
|
// Read-only
|
2018-01-21 13:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {boolean} isLast
|
|
|
|
* @default false
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
this.isLast = false;
|
|
|
|
|
|
|
|
// The frame that comes before this one in the animation (if any)
|
|
|
|
// Read-only
|
2018-01-21 13:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {?[type]} prevFrame
|
|
|
|
* @default null
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
this.prevFrame = null;
|
|
|
|
|
|
|
|
// The frame that comes after this one in the animation (if any)
|
|
|
|
// Read-only
|
2018-01-21 13:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {?[type]} nextFrame
|
|
|
|
* @default null
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
this.nextFrame = null;
|
|
|
|
|
|
|
|
// Additional time (in ms) this frame should appear for - added onto the msPerFrame
|
2018-01-21 13:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {number} duration
|
|
|
|
* @default 0
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
this.duration = 0;
|
|
|
|
|
|
|
|
// What % through the animation progress is this frame?
|
|
|
|
// Read-only
|
2018-01-21 13:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {number} progress
|
|
|
|
* @default 0
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
this.progress = 0;
|
|
|
|
|
|
|
|
// Callback if this frame gets displayed
|
2018-01-21 13:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {?[type]} onUpdate
|
|
|
|
* @default null
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
this.onUpdate = null;
|
|
|
|
|
|
|
|
// When this frame hits, set sprite.visible to this
|
2018-01-21 13:01:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @property {boolean} setVisible
|
|
|
|
* @default false
|
|
|
|
*/
|
2017-10-13 10:56:52 +00:00
|
|
|
this.setVisible = false;
|
|
|
|
|
|
|
|
this.visible = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
toJSON: function ()
|
|
|
|
{
|
|
|
|
return {
|
|
|
|
key: this.textureKey,
|
|
|
|
frame: this.textureFrame,
|
|
|
|
duration: this.duration,
|
|
|
|
visible: this.visible
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function ()
|
|
|
|
{
|
|
|
|
this.frame = undefined;
|
|
|
|
this.onUpdate = undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = AnimationFrame;
|