mirror of
https://github.com/photonstorm/phaser
synced 2024-12-27 13:33:35 +00:00
70 lines
1.6 KiB
JavaScript
70 lines
1.6 KiB
JavaScript
|
var Class = require('../../utils/Class');
|
||
|
|
||
|
// Phaser.Animations.AnimationFrame
|
||
|
|
||
|
var AnimationFrame = new Class({
|
||
|
|
||
|
initialize:
|
||
|
|
||
|
function AnimationFrame (textureKey, textureFrame, index, frame)
|
||
|
{
|
||
|
// The keys into the Texture Manager of the texture + frame this uses
|
||
|
this.textureKey = textureKey;
|
||
|
this.textureFrame = textureFrame;
|
||
|
|
||
|
// The index of this frame within the Animation.frames array
|
||
|
this.index = index;
|
||
|
|
||
|
// Texture Frame
|
||
|
this.frame = frame;
|
||
|
|
||
|
// Read-only
|
||
|
this.isFirst = false;
|
||
|
|
||
|
// Read-only
|
||
|
this.isLast = false;
|
||
|
|
||
|
// The frame that comes before this one in the animation (if any)
|
||
|
// Read-only
|
||
|
this.prevFrame = null;
|
||
|
|
||
|
// The frame that comes after this one in the animation (if any)
|
||
|
// Read-only
|
||
|
this.nextFrame = null;
|
||
|
|
||
|
// Additional time (in ms) this frame should appear for - added onto the msPerFrame
|
||
|
this.duration = 0;
|
||
|
|
||
|
// What % through the animation progress is this frame?
|
||
|
// Read-only
|
||
|
this.progress = 0;
|
||
|
|
||
|
// Callback if this frame gets displayed
|
||
|
this.onUpdate = null;
|
||
|
|
||
|
// When this frame hits, set sprite.visible to this
|
||
|
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;
|