mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 07:01:20 +00:00
Added Animation.removeFrame, removeFrameAt and getFrameAt.
This commit is contained in:
parent
ed5eda4bdc
commit
4ad87957bf
2 changed files with 42 additions and 1 deletions
|
@ -137,11 +137,18 @@ Animation.prototype = {
|
|||
this.paused = false;
|
||||
},
|
||||
|
||||
// config = Array of Animation config objects, like:
|
||||
// [
|
||||
// { key: 'gems', frame: 'diamond0001', [duration], [visible], [onUpdate] }
|
||||
// ]
|
||||
|
||||
// Add frames to the end of the animation
|
||||
addFrame: function (config)
|
||||
{
|
||||
return this.addFrameAt(0, config);
|
||||
return this.addFrameAt(this.frames.length, config);
|
||||
},
|
||||
|
||||
// Add frame/s into the animation
|
||||
addFrameAt: function (index, config)
|
||||
{
|
||||
if (index === undefined) { index = 0; }
|
||||
|
@ -172,6 +179,33 @@ Animation.prototype = {
|
|||
return this;
|
||||
},
|
||||
|
||||
getFrameAt: function (index)
|
||||
{
|
||||
return this.frames[index];
|
||||
},
|
||||
|
||||
// Remove frame if it matches the given frame
|
||||
removeFrame: function (frame)
|
||||
{
|
||||
var index = this.frames.indexOf(frame);
|
||||
|
||||
if (index !== -1)
|
||||
{
|
||||
this.removeFrameAt(index);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
removeFrameAt: function (index)
|
||||
{
|
||||
this.frames.splice(index, 1);
|
||||
|
||||
this.updateFrameSequence();
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
updateFrameSequence: function ()
|
||||
{
|
||||
var len = this.frames.length;
|
||||
|
|
|
@ -10,19 +10,25 @@ var Frame = function (textureKey, textureFrame, index, frame)
|
|||
// 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
|
||||
|
@ -30,6 +36,7 @@ var Frame = function (textureKey, textureFrame, index, frame)
|
|||
|
||||
// When this frame hits, set sprite.visible to this
|
||||
this.setVisible = false;
|
||||
|
||||
this.visible = false;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue