Add properties for MovieClip to loop and have a completed callback
This commit is contained in:
parent
c1c4d75a3d
commit
7bcdafaecf
1 changed files with 26 additions and 1 deletions
|
@ -33,6 +33,20 @@ PIXI.MovieClip = function(textures)
|
|||
* @type Number
|
||||
*/
|
||||
this.animationSpeed = 1;
|
||||
|
||||
/**
|
||||
* Whether or not the movie clip repeats after playing.
|
||||
* @property loop
|
||||
* @type Boolean
|
||||
*/
|
||||
this.loop = true;
|
||||
|
||||
/**
|
||||
* Function to call when a MovieClip finishes playing
|
||||
* @property onComplete
|
||||
* @type Function
|
||||
*/
|
||||
this.onComplete = null;
|
||||
|
||||
/**
|
||||
* [read only] indicates if the MovieClip is currently playing
|
||||
|
@ -96,5 +110,16 @@ PIXI.MovieClip.prototype.updateTransform = function()
|
|||
|
||||
this.currentFrame += this.animationSpeed;
|
||||
var round = (this.currentFrame + 0.5) | 0;
|
||||
this.setTexture(this.textures[round % this.textures.length]);
|
||||
if(this.loop || round <= this.textures.length)
|
||||
{
|
||||
this.setTexture(this.textures[round % this.textures.length]);
|
||||
}
|
||||
else if(round >= this.textures.length)
|
||||
{
|
||||
this.gotoAndStop(this.textures.length - 1);
|
||||
if(this.onComplete)
|
||||
{
|
||||
this.onComplete();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue