@@ -706,7 +706,8 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
706706 this._frameIndex = 0;
707707
708708 this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
709- this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
709+
710+ this._parent.setFrame(this.currentFrame);
710711
711712 // TODO: Double check if required
712713 if (this._parent.__tilePattern)
@@ -716,6 +717,7 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
716717 }
717718
718719 this._parent.events.onAnimationStart.dispatch(this._parent, this);
720+
719721 this.onStart.dispatch(this._parent, this);
720722
721723 return this;
@@ -741,6 +743,8 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
741743
742744 this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
743745
746+ this._parent.setFrame(this.currentFrame);
747+
744748 this.onStart.dispatch(this._parent, this);
745749
746750 },
@@ -823,6 +827,7 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
823827 if (resetFrame)
824828 {
825829 this.currentFrame = this._frameData.getFrame(this._frames[0]);
830+ this._parent.setFrame(this.currentFrame);
826831 }
827832
828833 if (dispatchComplete)
@@ -873,7 +878,7 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
873878 return false;
874879 }
875880
876- if (this.isPlaying === true && this.game.time.now > = this._timeNextFrame)
881+ if (this.isPlaying && this.game.time.now > = this._timeNextFrame)
877882 {
878883 this._frameSkip = 1;
879884
@@ -886,7 +891,6 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
886891 {
887892 // We need to skip a frame, work out how many
888893 this._frameSkip = Math.floor(this._frameDiff / this.delay);
889-
890894 this._frameDiff -= (this._frameSkip * this.delay);
891895 }
892896
@@ -901,18 +905,6 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
901905 {
902906 this._frameIndex %= this._frames.length;
903907 this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
904-
905- if (this.currentFrame)
906- {
907- this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
908-
909- if (this._parent.__tilePattern)
910- {
911- this._parent.__tilePattern = false;
912- this._parent.tilingTexture = false;
913- }
914- }
915-
916908 this.loopCount++;
917909 this._parent.events.onAnimationLoop.dispatch(this._parent, this);
918910 this.onLoop.dispatch(this._parent, this);
@@ -922,19 +914,17 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
922914 this.complete();
923915 }
924916 }
925- else
917+
918+ this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
919+
920+ if (this.currentFrame)
926921 {
927- this.currentFrame = this._frameData.getFrame (this._frames[this._frameIndex] );
922+ this._parent.setFrame (this.currentFrame );
928923
929- if (this.currentFrame )
924+ if (this._parent.__tilePattern )
930925 {
931- this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
932-
933- if (this._parent.__tilePattern)
934- {
935- this._parent.__tilePattern = false;
936- this._parent.tilingTexture = false;
937- }
926+ this._parent.__tilePattern = false;
927+ this._parent.tilingTexture = false;
938928 }
939929 }
940930
@@ -945,12 +935,101 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
945935
946936 },
947937
938+ /**
939+ * Advances by the given number of frames in the Animation, taking the loop value into consideration.
940+ *
941+ * @method Phaser.Animation#next
942+ * @param {number} [quantity=1] - The number of frames to advance.
943+ */
944+ next: function (quantity) {
945+
946+ if (typeof quantity === 'undefined') { quantity = 1; }
947+
948+ var frame = this._frameIndex + quantity;
949+
950+ if (frame > = this._frames.length)
951+ {
952+ if (this.loop)
953+ {
954+ frame %= this._frames.length;
955+ }
956+ else
957+ {
958+ frame = this._frames.length - 1;
959+ }
960+ }
961+
962+ if (frame !== this._frameIndex)
963+ {
964+ this._frameIndex = frame;
965+
966+ this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
967+
968+ if (this.currentFrame)
969+ {
970+ this._parent.setFrame(this.currentFrame);
971+
972+ if (this._parent.__tilePattern)
973+ {
974+ this._parent.__tilePattern = false;
975+ this._parent.tilingTexture = false;
976+ }
977+ }
978+ }
979+
980+ },
981+
982+ /**
983+ * Moves backwards the given number of frames in the Animation, taking the loop value into consideration.
984+ *
985+ * @method Phaser.Animation#previous
986+ * @param {number} [quantity=1] - The number of frames to move back.
987+ */
988+ previous: function (quantity) {
989+
990+ if (typeof quantity === 'undefined') { quantity = 1; }
991+
992+ var frame = this._frameIndex - quantity;
993+
994+ if (frame < 0)
995+ {
996+ if (this.loop)
997+ {
998+ frame = this._frames.length + frame;
999+ }
1000+ else
1001+ {
1002+ frame++;
1003+ }
1004+ }
1005+
1006+ if (frame !== this._frameIndex)
1007+ {
1008+ this._frameIndex = frame;
1009+
1010+ this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
1011+
1012+ if (this.currentFrame)
1013+ {
1014+ this._parent.setFrame(this.currentFrame);
1015+
1016+ if (this._parent.__tilePattern)
1017+ {
1018+ this._parent.__tilePattern = false;
1019+ this._parent.tilingTexture = false;
1020+ }
1021+ }
1022+ }
1023+
1024+ },
1025+
9481026 /**
9491027 * Cleans up this animation ready for deletion. Nulls all values and references.
9501028 *
9511029 * @method Phaser.Animation#destroy
9521030 */
9531031 destroy: function () {
1032+
9541033 this.game.onPause.remove(this.onPause, this);
9551034 this.game.onResume.remove(this.onResume, this);
9561035
@@ -1067,7 +1146,7 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
10671146 if (this.currentFrame !== null)
10681147 {
10691148 this._frameIndex = value;
1070- this._parent.setTexture(PIXI.TextureCache[ this.currentFrame.uuid] );
1149+ this._parent.setFrame( this.currentFrame);
10711150 }
10721151
10731152 }
@@ -1180,7 +1259,7 @@ <h1 class="page-title">Source: animation/Animation.js</h1>
11801259
11811260 < span class ="jsdoc-message ">
11821261 Documentation generated by < a href ="https://github.com/jsdoc3/jsdoc "> JSDoc 3.3.0-dev</ a >
1183- on Tue May 20 2014 10:05:49 GMT+0100 (BST) using the < a href ="https://github.com/terryweiss/docstrap "> DocStrap template</ a > .
1262+ on Thu Jul 10 2014 20:18:55 GMT+0100 (BST) using the < a href ="https://github.com/terryweiss/docstrap "> DocStrap template</ a > .
11841263 </ span >
11851264 </ footer >
11861265 </ div >
0 commit comments