77*
88* Phaser - http://phaser.io
99*
10- * v2.4.0 "Katar" - Built: Thu May 14 2015 16:47:28
10+ * v2.4.0 "Katar" - Built: Mon May 18 2015 12:55:12
1111*
1212* By Richard Davey http://www.photonstorm.com @photonstorm
1313*
@@ -36625,7 +36625,7 @@ Phaser.Device = function () {
3662536625 * @property {boolean} getUserMedia - Does the device support the getUserMedia API?
3662636626 * @default
3662736627 */
36628- this.getUserMedia = false ;
36628+ this.getUserMedia = true ;
3662936629
3663036630 /**
3663136631 * @property {boolean} quirksMode - Is the browser running in strict mode (false) or quirks mode? (true)
@@ -37117,7 +37117,20 @@ Phaser.Device._initialize = function () {
3711737117
3711837118 device.quirksMode = (document.compatMode === 'CSS1Compat') ? false : true;
3711937119
37120- device.getUserMedia = !!(navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
37120+ navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
37121+
37122+ window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
37123+
37124+ device.getUserMedia = device.getUserMedia && !!navigator.getUserMedia && !!window.URL;
37125+
37126+ // Older versions of firefox (< 21) apparently claim support but user media does not actually work
37127+ if (navigator.userAgent.match(/Firefox\D+(\d+)/))
37128+ {
37129+ if (parseInt(RegExp.$1, 10) < 21)
37130+ {
37131+ device.getUserMedia = false;
37132+ }
37133+ }
3712137134
3712237135 // TODO: replace canvasBitBltShift detection with actual feature check
3712337136
@@ -39169,7 +39182,7 @@ Phaser.Math = {
3916939182 */
3917039183 isOdd: function (n) {
3917139184 // Does not work with extremely large values
39172- return (n & 1);
39185+ return !! (n & 1);
3917339186 },
3917439187
3917539188 /**
@@ -41950,7 +41963,10 @@ Phaser.AnimationManager = function (sprite) {
4195041963 this.game = sprite.game;
4195141964
4195241965 /**
41953- * @property {Phaser.Frame} currentFrame - The currently displayed Frame of animation, if any.
41966+ * The currently displayed Frame of animation, if any.
41967+ * This property is only set once an Animation starts playing. Until that point it remains set as `null`.
41968+ *
41969+ * @property {Phaser.Frame} currentFrame
4195441970 * @default
4195541971 */
4195641972 this.currentFrame = null;
@@ -42121,14 +42137,16 @@ Phaser.AnimationManager.prototype = {
4212142137 }
4212242138 }
4212342139
42124- this._outputFrames.length = 0 ;
42140+ this._outputFrames = [] ;
4212542141
4212642142 this._frameData.getFrameIndexes(frames, useNumericIndex, this._outputFrames);
4212742143
4212842144 this._anims[name] = new Phaser.Animation(this.game, this.sprite, name, this._frameData, this._outputFrames, frameRate, loop);
4212942145
4213042146 this.currentAnim = this._anims[name];
42131- this.currentFrame = this.currentAnim.currentFrame;
42147+
42148+ // This shouldn't be set until the Animation is played, surely?
42149+ // this.currentFrame = this.currentAnim.currentFrame;
4213242150
4213342151 if (this.sprite.tilingTexture)
4213442152 {
@@ -42197,6 +42215,7 @@ Phaser.AnimationManager.prototype = {
4219742215 this.currentAnim.paused = false;
4219842216 return this.currentAnim.play(frameRate, loop, killOnComplete);
4219942217 }
42218+
4220042219 return this.currentAnim;
4220142220 }
4220242221 else
@@ -42691,7 +42710,7 @@ Phaser.Animation.prototype = {
4269142710 this._timeNextFrame = this.game.time.time + this.delay;
4269242711
4269342712 this._frameIndex = 0;
42694- this.updateCurrentFrame(false);
42713+ this.updateCurrentFrame(false, true );
4269542714
4269642715 this._parent.events.onAnimationStart$dispatch(this._parent, this);
4269742716
@@ -42880,6 +42899,7 @@ Phaser.Animation.prototype = {
4288042899 // And what's left now?
4288142900 this._timeNextFrame = this.game.time.time + (this.delay - this._frameDiff);
4288242901
42902+ var fi = this._frameIndex;
4288342903 this._frameIndex += this._frameSkip;
4288442904
4288542905 if (this._frameIndex >= this._frames.length)
@@ -42917,24 +42937,39 @@ Phaser.Animation.prototype = {
4291742937 * Returns true if the current frame update was 'successful', false otherwise.
4291842938 *
4291942939 * @method Phaser.Animation#updateCurrentFrame
42920- * @param {bool} signalUpdate - If true th onUpdate signal will be triggered.
42940+ * @param {boolean} signalUpdate - If true the `Animation.onUpdate` signal will be dispatched.
42941+ * @param {boolean} fromPlay - Was this call made from the playing of a new animation?
4292142942 * @private
4292242943 */
42923- updateCurrentFrame: function (signalUpdate) {
42944+ updateCurrentFrame: function (signalUpdate, fromPlay) {
42945+
42946+ if (typeof fromPlay === 'undefined') { fromPlay = false; }
4292442947
4292542948 if (!this._frameData)
4292642949 {
4292742950 // The animation is already destroyed, probably from a callback
4292842951 return false;
4292942952 }
4293042953
42931- var idx = this.currentFrame.index;
42932-
42933- this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
42954+ if (fromPlay)
42955+ {
42956+ this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
4293442957
42935- if (this.currentFrame && idx !== this.currentFrame.index)
42958+ if (this.currentFrame && idx !== this.currentFrame.index)
42959+ {
42960+ this._parent.setFrame(this.currentFrame);
42961+ }
42962+ }
42963+ else
4293642964 {
42937- this._parent.setFrame(this.currentFrame);
42965+ var idx = this.currentFrame.index;
42966+
42967+ this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
42968+
42969+ if (this.currentFrame && idx !== this.currentFrame.index)
42970+ {
42971+ this._parent.setFrame(this.currentFrame);
42972+ }
4293842973 }
4293942974
4294042975 if (this.onUpdate && signalUpdate)
@@ -43543,7 +43578,6 @@ Phaser.FrameData = function () {
4354343578 */
4354443579 this._frames = [];
4354543580
43546-
4354743581 /**
4354843582 * @property {Array} _frameNames - Local array of frame names for name to index conversions.
4354943583 * @private
@@ -43685,7 +43719,7 @@ Phaser.FrameData.prototype = {
4368543719 * The frames are returned in the output array, or if none is provided in a new Array object.
4368643720 *
4368743721 * @method Phaser.FrameData#getFrames
43688- * @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
43722+ * @param {Array} [ frames] - An Array containing the indexes of the frames to retrieve. If the array is empty or undefined then all frames in the FrameData are returned.
4368943723 * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false)
4369043724 * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
4369143725 * @return {Array} An array of all Frames in this FrameData set matching the given names or IDs.
@@ -43732,7 +43766,7 @@ Phaser.FrameData.prototype = {
4373243766 * The frames indexes are returned in the output array, or if none is provided in a new Array object.
4373343767 *
4373443768 * @method Phaser.FrameData#getFrameIndexes
43735- * @param {Array} frames - An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
43769+ * @param {Array} [ frames] - An Array containing the indexes of the frames to retrieve. If undefined or the array is empty then all frames in the FrameData are returned.
4373643770 * @param {boolean} [useNumericIndex=true] - Are the given frames using numeric indexes (default) or strings? (false)
4373743771 * @param {Array} [output] - If given the results will be appended to the end of this array otherwise a new array will be created.
4373843772 * @return {Array} An array of all Frame indexes matching the given names or IDs.
@@ -43753,12 +43787,12 @@ Phaser.FrameData.prototype = {
4375343787 else
4375443788 {
4375543789 // Input array given, loop through that instead
43756- for (var i = 0; i < this._frames .length; i++)
43790+ for (var i = 0; i < frames .length; i++)
4375743791 {
4375843792 // Does the frames array contain names or indexes?
4375943793 if (useNumericIndex)
4376043794 {
43761- output.push(frames[i]);
43795+ output.push(this._frames[ frames[i]].index );
4376243796 }
4376343797 else
4376443798 {
@@ -47253,7 +47287,7 @@ Phaser.Loader.prototype = {
4725347287 * for previous assets to load (unless they are sync-points). Resources, such as packs, may still
4725447288 * be downloaded around sync-points, as long as they do not finalize loading.
4725547289 *
47256- * @method Phader .Loader#withSyncPoints
47290+ * @method Phaser .Loader#withSyncPoints
4725747291 * @param {function} callback - The callback is invoked and is supplied with a single argument: the loader.
4725847292 * @param {object} [callbackContext=(loader)] - Context for the callback.
4725947293 * @return {Phaser.Loader} This Loader instance.
@@ -47276,9 +47310,9 @@ Phaser.Loader.prototype = {
4727647310 *
4727747311 * This has no effect on already loaded assets.
4727847312 *
47279- * @method Phader .Loader#withSyncPoints
47280- * @param {function} callback - The callback is invoked and is supplied with a single argument: the loader .
47281- * @param {object} [callbackContext=(loader)] - Context for the callback .
47313+ * @method Phaser .Loader#addSyncPoint
47314+ * @param {string} type - The type of resource to turn into a sync point (image, audio, xml, etc) .
47315+ * @param {string} key - Key of the file you want to turn into a sync point .
4728247316 * @return {Phaser.Loader} This Loader instance.
4728347317 * @see {@link Phaser.Loader#withSyncPoint withSyncPoint}
4728447318 */
@@ -47837,20 +47871,20 @@ Phaser.Loader.prototype = {
4783747871
4783847872 file.data = document.createElement("video");
4783947873 file.data.name = file.key;
47874+ file.data.controls = false;
47875+ file.data.autoplay = false;
4784047876
4784147877 var playThroughEvent = function () {
47842- file.data.removeEventListener('canplay ', playThroughEvent, false );
47878+ // console.log('playThroughEvent ', file.data.name );
4784347879 file.data.removeEventListener('canplaythrough', playThroughEvent, false);
47844- file.data.removeEventListener('loadeddata', playThroughEvent, false);
4784547880 file.data.onerror = null;
4784647881 file.data.canplay = true;
4784747882 // Why does this cycle through games?
4784847883 Phaser.GAMES[_this.game.id].load.fileComplete(file);
4784947884 };
4785047885
4785147886 var loadedDataEvent = function () {
47852- file.data.removeEventListener('canplay', playThroughEvent, false);
47853- file.data.removeEventListener('canplaythrough', playThroughEvent, false);
47887+ // console.log('loadedDataEvent', file.data.name);
4785447888 file.data.removeEventListener('loadeddata', loadedDataEvent, false);
4785547889 file.data.onerror = null;
4785647890 file.data.canplay = false;
@@ -47859,19 +47893,25 @@ Phaser.Loader.prototype = {
4785947893 };
4786047894
4786147895 file.data.onerror = function () {
47862- file.data.removeEventListener('canplay', playThroughEvent, false);
47896+ // file.data.removeEventListener('canplay', playThroughEvent, false);
4786347897 file.data.removeEventListener('canplaythrough', playThroughEvent, false);
4786447898 file.data.removeEventListener('loadeddata', playThroughEvent, false);
4786547899 file.data.onerror = null;
4786647900 file.data.canplay = false;
4786747901 _this.fileError(file);
4786847902 };
4786947903
47870- file.data.controls = false;
47871- file.data.autoplay = false;
47872- file.data.addEventListener('canplay', playThroughEvent, false);
47873- file.data.addEventListener('canplaythrough', playThroughEvent, false);
47874- file.data.addEventListener('loadeddata', loadedDataEvent, false);
47904+ if (this.game.device.firefox)
47905+ {
47906+ // I wish there was another easier way, but I'm not aware of it yet
47907+ file.data.addEventListener('loadeddata', loadedDataEvent, false);
47908+ }
47909+ else
47910+ {
47911+ // file.data.addEventListener('canplay', playThroughEvent, false);
47912+ file.data.addEventListener('canplaythrough', playThroughEvent, false);
47913+ }
47914+
4787547915 file.data.src = this.transformUrl(file.url, file);
4787647916 file.data.load();
4787747917
0 commit comments