phaser-rails 2.2.1.0 → 2.2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4127217485ff32d6949f7270a68a105f9d96903
4
- data.tar.gz: e8899369c9f83ec1a9ab60274ae47d412a3b52d9
3
+ metadata.gz: 406e165afd9d4c99bf8f3f18f46b1cbf506381a2
4
+ data.tar.gz: 3e5f3d7c71231c8ccce39b737215c460e1094c20
5
5
  SHA512:
6
- metadata.gz: e4ed901b83ffc1654d777e7e56467222b2fb41f29c82df7098ed879a945990312948ef1d3d295c689326999b3ae56aa933734940d1be741b402d5a419d911d73
7
- data.tar.gz: 9480c03e6b031949a82b372edded87cad98292f02ba4d3cc2981e2e8a058eb3ffac99d993828d94fb5d6ae800bb2392f20f13d9bce559a0bf6ffa923dfbf1d79
6
+ metadata.gz: 8205c3d8a2c7f86cd91578136ab98122c2667693d3f398205c32b68b89f97deacf12366e0e7a70d341f6ff81c1a6adadd1c65f108bcaba1805a16ba36d7655aa
7
+ data.tar.gz: a34d5ad94eeab82756eeb992213704d000249c58a76fa4bbde159cacdbd3d137b74b9936b1150fadcaef0acf95f8210cf16454d961cfdff71cbf0830d20c4c9f
@@ -1,5 +1,5 @@
1
1
  module Phaser
2
2
  module Rails
3
- VERSION = "2.2.1.0"
3
+ VERSION = "2.2.2.0"
4
4
  end
5
5
  end
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * Phaser - http://phaser.io
9
9
  *
10
- * v2.2.1 "Danabar" - Built: Thu Dec 04 2014 11:31:00
10
+ * v2.2.2 "Alkindar" - Built: Tue Jan 06 2015 06:57:43
11
11
  *
12
12
  * By Richard Davey http://www.photonstorm.com @photonstorm
13
13
  *
@@ -77,7 +77,7 @@ PIXI.CANVAS_RENDERER = 1;
77
77
  PIXI.VERSION = "v2.2.0";
78
78
 
79
79
  /**
80
- * Various blend modes supported by pixi.
80
+ * Various blend modes supported by pixi. IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes.
81
81
  * @property {Object} blendModes
82
82
  * @property {Number} blendModes.NORMAL
83
83
  * @property {Number} blendModes.ADD
@@ -281,7 +281,21 @@ PIXI.Polygon = function(points)
281
281
  }
282
282
 
283
283
  this.closed = true;
284
+
285
+ /**
286
+ * An array of the points of this polygon
287
+ * @property points
288
+ * @type Array(Point)|Array(Number)
289
+ *
290
+ */
284
291
  this.points = points;
292
+
293
+ /**
294
+ * The type of the object, should be one of the Graphics type consts, PIXI.Graphics.POLY in this case
295
+ * @property type
296
+ * @type Number
297
+ * @default 0
298
+ */
285
299
  };
286
300
 
287
301
  /**
@@ -639,6 +653,13 @@ PIXI.Rectangle = function(x, y, width, height)
639
653
  * @default 0
640
654
  */
641
655
  this.height = height || 0;
656
+
657
+ /**
658
+ * The type of the object, should be one of the Graphics type consts, PIXI.Graphics.RECT in this case
659
+ * @property type
660
+ * @type Number
661
+ * @default 0
662
+ */
642
663
  };
643
664
 
644
665
  /**
@@ -696,7 +717,7 @@ PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0);
696
717
  * @param y {Number} The Y coordinate of the upper-left corner of the rounded rectangle
697
718
  * @param width {Number} The overall width of this rounded rectangle
698
719
  * @param height {Number} The overall height of this rounded rectangle
699
- * @param radius {Number} The overall radius of this corners of this rounded rectangle
720
+ * @param radius {Number} Controls the radius of the rounded corners
700
721
  */
701
722
  PIXI.RoundedRectangle = function(x, y, width, height, radius)
702
723
  {
@@ -734,6 +755,13 @@ PIXI.RoundedRectangle = function(x, y, width, height, radius)
734
755
  * @default 20
735
756
  */
736
757
  this.radius = radius || 20;
758
+
759
+ /**
760
+ * The type of the object, should be one of the Graphics type consts, PIXI.Graphics.RRECT in this case
761
+ * @property type
762
+ * @type Number
763
+ * @default 0
764
+ */
737
765
  };
738
766
 
739
767
  /**
@@ -2968,6 +2996,10 @@ PIXI.Text.prototype.updateText = function()
2968
2996
 
2969
2997
  if(navigator.isCocoonJS) this.context.clearRect(0,0,this.canvas.width,this.canvas.height);
2970
2998
 
2999
+ // used for debugging..
3000
+ //this.context.fillStyle ="#FF0000"
3001
+ //this.context.fillRect(0, 0, this.canvas.width,this.canvas.height);
3002
+
2971
3003
  this.context.font = this.style.font;
2972
3004
  this.context.strokeStyle = this.style.stroke;
2973
3005
  this.context.lineWidth = this.style.strokeThickness;
@@ -3196,6 +3228,8 @@ PIXI.Text.prototype.determineFontProperties = function(fontStyle)
3196
3228
  }
3197
3229
 
3198
3230
  properties.descent = i - baseline;
3231
+ //TODO might need a tweak. kind of a temp fix!
3232
+ properties.descent += 6;
3199
3233
  properties.fontSize = properties.ascent + properties.descent;
3200
3234
 
3201
3235
  PIXI.Text.fontPropertiesCache[fontStyle] = properties;
@@ -3848,9 +3882,18 @@ PIXI.getNextPowerOfTwo = function(number)
3848
3882
  return result;
3849
3883
  }
3850
3884
  };
3885
+
3886
+ /**
3887
+ * checks if the given width and height make a power of two texture
3888
+ * @method isPowerOfTwo
3889
+ * @param width {Number}
3890
+ * @param height {Number}
3891
+ * @return {Boolean}
3892
+ */
3851
3893
  PIXI.isPowerOfTwo = function(width, height)
3852
3894
  {
3853
3895
  return (width > 0 && (width & (width - 1)) === 0 && height > 0 && (height & (height - 1)) === 0);
3896
+
3854
3897
  };
3855
3898
 
3856
3899
  /**
@@ -5122,13 +5165,14 @@ PIXI.PrimitiveShader = function(gl)
5122
5165
  'uniform vec2 projectionVector;',
5123
5166
  'uniform vec2 offsetVector;',
5124
5167
  'uniform float alpha;',
5168
+ 'uniform float flipY;',
5125
5169
  'uniform vec3 tint;',
5126
5170
  'varying vec4 vColor;',
5127
5171
 
5128
5172
  'void main(void) {',
5129
5173
  ' vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);',
5130
5174
  ' v -= offsetVector.xyx;',
5131
- ' gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);',
5175
+ ' gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);',
5132
5176
  ' vColor = aColor * vec4(tint * alpha, alpha);',
5133
5177
  '}'
5134
5178
  ];
@@ -5154,6 +5198,7 @@ PIXI.PrimitiveShader.prototype.init = function()
5154
5198
  this.projectionVector = gl.getUniformLocation(program, 'projectionVector');
5155
5199
  this.offsetVector = gl.getUniformLocation(program, 'offsetVector');
5156
5200
  this.tintColor = gl.getUniformLocation(program, 'tint');
5201
+ this.flipY = gl.getUniformLocation(program, 'flipY');
5157
5202
 
5158
5203
  // get and store the attributes
5159
5204
  this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition');
@@ -5243,13 +5288,13 @@ PIXI.ComplexPrimitiveShader = function(gl)
5243
5288
  'uniform vec3 tint;',
5244
5289
  'uniform float alpha;',
5245
5290
  'uniform vec3 color;',
5246
-
5291
+ 'uniform float flipY;',
5247
5292
  'varying vec4 vColor;',
5248
5293
 
5249
5294
  'void main(void) {',
5250
5295
  ' vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);',
5251
5296
  ' v -= offsetVector.xyx;',
5252
- ' gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);',
5297
+ ' gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);',
5253
5298
  ' vColor = vec4(color * alpha * tint, alpha);',//" * vec4(tint * alpha, alpha);',
5254
5299
  '}'
5255
5300
  ];
@@ -5276,6 +5321,7 @@ PIXI.ComplexPrimitiveShader.prototype.init = function()
5276
5321
  this.offsetVector = gl.getUniformLocation(program, 'offsetVector');
5277
5322
  this.tintColor = gl.getUniformLocation(program, 'tint');
5278
5323
  this.color = gl.getUniformLocation(program, 'color');
5324
+ this.flipY = gl.getUniformLocation(program, 'flipY');
5279
5325
 
5280
5326
  // get and store the attributes
5281
5327
  this.aVertexPosition = gl.getAttribLocation(program, 'aVertexPosition');
@@ -5365,7 +5411,9 @@ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projectio
5365
5411
  renderSession.shaderManager.setShader( shader );//activatePrimitiveShader();
5366
5412
  shader = renderSession.shaderManager.primitiveShader;
5367
5413
  gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true));
5368
-
5414
+
5415
+ gl.uniform1f(shader.flipY, 1);
5416
+
5369
5417
  gl.uniform2f(shader.projectionVector, projection.x, -projection.y);
5370
5418
  gl.uniform2f(shader.offsetVector, -offset.x, -offset.y);
5371
5419
 
@@ -5654,6 +5702,8 @@ PIXI.WebGLGraphics.buildRoundedRectangle = function(graphicsData, webGLData)
5654
5702
 
5655
5703
  var triangles = PIXI.PolyK.Triangulate(recPoints);
5656
5704
 
5705
+ //
5706
+
5657
5707
  var i = 0;
5658
5708
  for (i = 0; i < triangles.length; i+=3)
5659
5709
  {
@@ -5664,6 +5714,7 @@ PIXI.WebGLGraphics.buildRoundedRectangle = function(graphicsData, webGLData)
5664
5714
  indices.push(triangles[i+2] + vecPos);
5665
5715
  }
5666
5716
 
5717
+
5667
5718
  for (i = 0; i < recPoints.length; i++)
5668
5719
  {
5669
5720
  verts.push(recPoints[i], recPoints[++i], r, g, b, alpha);
@@ -6553,6 +6604,9 @@ PIXI.WebGLRenderer.prototype.renderDisplayObject = function(displayObject, proje
6553
6604
  // reset the render session data..
6554
6605
  this.renderSession.drawCount = 0;
6555
6606
 
6607
+ // make sure to flip the Y if using a render texture..
6608
+ this.renderSession.flipY = buffer ? -1 : 1;
6609
+
6556
6610
  // set the default projection
6557
6611
  this.renderSession.projection = projection;
6558
6612
 
@@ -7021,6 +7075,8 @@ PIXI.WebGLStencilManager.prototype.bindGraphics = function(graphics, webGLData,
7021
7075
 
7022
7076
  renderSession.shaderManager.setShader( shader );
7023
7077
 
7078
+ gl.uniform1f(shader.flipY, renderSession.flipY);
7079
+
7024
7080
  gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true));
7025
7081
 
7026
7082
  gl.uniform2f(shader.projectionVector, projection.x, -projection.y);
@@ -7048,6 +7104,7 @@ PIXI.WebGLStencilManager.prototype.bindGraphics = function(graphics, webGLData,
7048
7104
 
7049
7105
  gl.uniformMatrix3fv(shader.translationMatrix, false, graphics.worldTransform.toArray(true));
7050
7106
 
7107
+ gl.uniform1f(shader.flipY, renderSession.flipY);
7051
7108
  gl.uniform2f(shader.projectionVector, projection.x, -projection.y);
7052
7109
  gl.uniform2f(shader.offsetVector, -offset.x, -offset.y);
7053
7110
 
@@ -8189,7 +8246,7 @@ PIXI.WebGLFastSpriteBatch.prototype.renderSprite = function(sprite)
8189
8246
  if(!sprite.texture._uvs)return;
8190
8247
  }
8191
8248
 
8192
- var uvs, verticies = this.vertices, width, height, w0, w1, h0, h1, index;
8249
+ var uvs, vertices = this.vertices, width, height, w0, w1, h0, h1, index;
8193
8250
 
8194
8251
  uvs = sprite.texture._uvs;
8195
8252
 
@@ -8219,89 +8276,89 @@ PIXI.WebGLFastSpriteBatch.prototype.renderSprite = function(sprite)
8219
8276
  index = this.currentBatchSize * 4 * this.vertSize;
8220
8277
 
8221
8278
  // xy
8222
- verticies[index++] = w1;
8223
- verticies[index++] = h1;
8279
+ vertices[index++] = w1;
8280
+ vertices[index++] = h1;
8224
8281
 
8225
- verticies[index++] = sprite.position.x;
8226
- verticies[index++] = sprite.position.y;
8282
+ vertices[index++] = sprite.position.x;
8283
+ vertices[index++] = sprite.position.y;
8227
8284
 
8228
8285
  //scale
8229
- verticies[index++] = sprite.scale.x;
8230
- verticies[index++] = sprite.scale.y;
8286
+ vertices[index++] = sprite.scale.x;
8287
+ vertices[index++] = sprite.scale.y;
8231
8288
 
8232
8289
  //rotation
8233
- verticies[index++] = sprite.rotation;
8290
+ vertices[index++] = sprite.rotation;
8234
8291
 
8235
8292
  // uv
8236
- verticies[index++] = uvs.x0;
8237
- verticies[index++] = uvs.y1;
8293
+ vertices[index++] = uvs.x0;
8294
+ vertices[index++] = uvs.y1;
8238
8295
  // color
8239
- verticies[index++] = sprite.alpha;
8296
+ vertices[index++] = sprite.alpha;
8240
8297
 
8241
8298
 
8242
8299
  // xy
8243
- verticies[index++] = w0;
8244
- verticies[index++] = h1;
8300
+ vertices[index++] = w0;
8301
+ vertices[index++] = h1;
8245
8302
 
8246
- verticies[index++] = sprite.position.x;
8247
- verticies[index++] = sprite.position.y;
8303
+ vertices[index++] = sprite.position.x;
8304
+ vertices[index++] = sprite.position.y;
8248
8305
 
8249
8306
  //scale
8250
- verticies[index++] = sprite.scale.x;
8251
- verticies[index++] = sprite.scale.y;
8307
+ vertices[index++] = sprite.scale.x;
8308
+ vertices[index++] = sprite.scale.y;
8252
8309
 
8253
8310
  //rotation
8254
- verticies[index++] = sprite.rotation;
8311
+ vertices[index++] = sprite.rotation;
8255
8312
 
8256
8313
  // uv
8257
- verticies[index++] = uvs.x1;
8258
- verticies[index++] = uvs.y1;
8314
+ vertices[index++] = uvs.x1;
8315
+ vertices[index++] = uvs.y1;
8259
8316
  // color
8260
- verticies[index++] = sprite.alpha;
8317
+ vertices[index++] = sprite.alpha;
8261
8318
 
8262
8319
 
8263
8320
  // xy
8264
- verticies[index++] = w0;
8265
- verticies[index++] = h0;
8321
+ vertices[index++] = w0;
8322
+ vertices[index++] = h0;
8266
8323
 
8267
- verticies[index++] = sprite.position.x;
8268
- verticies[index++] = sprite.position.y;
8324
+ vertices[index++] = sprite.position.x;
8325
+ vertices[index++] = sprite.position.y;
8269
8326
 
8270
8327
  //scale
8271
- verticies[index++] = sprite.scale.x;
8272
- verticies[index++] = sprite.scale.y;
8328
+ vertices[index++] = sprite.scale.x;
8329
+ vertices[index++] = sprite.scale.y;
8273
8330
 
8274
8331
  //rotation
8275
- verticies[index++] = sprite.rotation;
8332
+ vertices[index++] = sprite.rotation;
8276
8333
 
8277
8334
  // uv
8278
- verticies[index++] = uvs.x2;
8279
- verticies[index++] = uvs.y2;
8335
+ vertices[index++] = uvs.x2;
8336
+ vertices[index++] = uvs.y2;
8280
8337
  // color
8281
- verticies[index++] = sprite.alpha;
8338
+ vertices[index++] = sprite.alpha;
8282
8339
 
8283
8340
 
8284
8341
 
8285
8342
 
8286
8343
  // xy
8287
- verticies[index++] = w1;
8288
- verticies[index++] = h0;
8344
+ vertices[index++] = w1;
8345
+ vertices[index++] = h0;
8289
8346
 
8290
- verticies[index++] = sprite.position.x;
8291
- verticies[index++] = sprite.position.y;
8347
+ vertices[index++] = sprite.position.x;
8348
+ vertices[index++] = sprite.position.y;
8292
8349
 
8293
8350
  //scale
8294
- verticies[index++] = sprite.scale.x;
8295
- verticies[index++] = sprite.scale.y;
8351
+ vertices[index++] = sprite.scale.x;
8352
+ vertices[index++] = sprite.scale.y;
8296
8353
 
8297
8354
  //rotation
8298
- verticies[index++] = sprite.rotation;
8355
+ vertices[index++] = sprite.rotation;
8299
8356
 
8300
8357
  // uv
8301
- verticies[index++] = uvs.x3;
8302
- verticies[index++] = uvs.y3;
8358
+ vertices[index++] = uvs.x3;
8359
+ vertices[index++] = uvs.y3;
8303
8360
  // color
8304
- verticies[index++] = sprite.alpha;
8361
+ vertices[index++] = sprite.alpha;
8305
8362
 
8306
8363
  // increment the batchs
8307
8364
  this.currentBatchSize++;
@@ -9244,7 +9301,7 @@ PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas)
9244
9301
  */
9245
9302
  PIXI.CanvasTinter.tintWithPerPixel = function(texture, color, canvas)
9246
9303
  {
9247
- var context = canvas.getContext( "2d" );
9304
+ var context = canvas.getContext("2d");
9248
9305
 
9249
9306
  var crop = texture.crop;
9250
9307
 
@@ -9271,9 +9328,18 @@ PIXI.CanvasTinter.tintWithPerPixel = function(texture, color, canvas)
9271
9328
 
9272
9329
  for (var i = 0; i < pixels.length; i += 4)
9273
9330
  {
9274
- pixels[i+0] *= r;
9275
- pixels[i+1] *= g;
9276
- pixels[i+2] *= b;
9331
+ pixels[i+0] *= r;
9332
+ pixels[i+1] *= g;
9333
+ pixels[i+2] *= b;
9334
+
9335
+ if (!PIXI.CanvasTinter.canHandleAlpha)
9336
+ {
9337
+ var alpha = pixels[i+3];
9338
+
9339
+ pixels[i+0] /= 255 / alpha;
9340
+ pixels[i+1] /= 255 / alpha;
9341
+ pixels[i+2] /= 255 / alpha;
9342
+ }
9277
9343
  }
9278
9344
 
9279
9345
  context.putImageData(pixelData, 0, 0);
@@ -9299,6 +9365,35 @@ PIXI.CanvasTinter.roundColor = function(color)
9299
9365
  return PIXI.rgb2hex(rgbValues);
9300
9366
  };
9301
9367
 
9368
+ /**
9369
+ * Rounds the specified color according to the PIXI.CanvasTinter.cacheStepsPerColorChannel.
9370
+ *
9371
+ * @method roundColor
9372
+ * @static
9373
+ * @param color {number} the color to round, should be a hex color
9374
+ */
9375
+ PIXI.CanvasTinter.checkInverseAlpha = function()
9376
+ {
9377
+ var canvas = new PIXI.CanvasBuffer(2, 1);
9378
+
9379
+ canvas.context.fillStyle = "rgba(10, 20, 30, 0.5)";
9380
+
9381
+ // Draw a single pixel
9382
+ canvas.context.fillRect(0, 0, 1, 1);
9383
+
9384
+ // Get the color values
9385
+ var s1 = canvas.context.getImageData(0, 0, 1, 1);
9386
+
9387
+ // Plot them to x2
9388
+ canvas.context.putImageData(s1, 1, 0);
9389
+
9390
+ // Get those values
9391
+ var s2 = canvas.context.getImageData(1, 0, 1, 1);
9392
+
9393
+ // Compare and return
9394
+ return (s2.data[0] === s1.data[0] && s2.data[1] === s1.data[1] && s2.data[2] === s1.data[2] && s2.data[3] === s1.data[3]);
9395
+ };
9396
+
9302
9397
  /**
9303
9398
  * Number of steps which will be used as a cap when rounding colors.
9304
9399
  *
@@ -9317,6 +9412,16 @@ PIXI.CanvasTinter.cacheStepsPerColorChannel = 8;
9317
9412
  */
9318
9413
  PIXI.CanvasTinter.convertTintToImage = false;
9319
9414
 
9415
+ /**
9416
+ * If the browser isn't capable of handling tinting with alpha this will be false.
9417
+ * This property is only applicable if using tintWithPerPixel.
9418
+ *
9419
+ * @property canHandleAlpha
9420
+ * @type Boolean
9421
+ * @static
9422
+ */
9423
+ PIXI.CanvasTinter.canHandleAlpha = PIXI.CanvasTinter.checkInverseAlpha();
9424
+
9320
9425
  /**
9321
9426
  * Whether or not the Canvas BlendModes are supported, consequently the ability to tint using the multiply method.
9322
9427
  *
@@ -10853,10 +10958,8 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
10853
10958
 
10854
10959
  if (this.tilingTexture && this.tilingTexture.needsUpdate)
10855
10960
  {
10856
- //TODO - tweaking
10857
- PIXI.updateWebGLTexture(this.tilingTexture.baseTexture, renderSession.gl);
10961
+ renderSession.renderer.updateTexture(this.tilingTexture.baseTexture);
10858
10962
  this.tilingTexture.needsUpdate = false;
10859
- // this.tilingTexture._uvs = null;
10860
10963
  }
10861
10964
  }
10862
10965
  else
@@ -12225,7 +12328,7 @@ PIXI.AbstractFilter.prototype.apply = function(frameBuffer)
12225
12328
  *
12226
12329
  * Phaser - http://phaser.io
12227
12330
  *
12228
- * v2.2.1 "Danabar" - Built: Thu Dec 04 2014 11:31:00
12331
+ * v2.2.2 "Alkindar" - Built: Tue Jan 06 2015 06:57:42
12229
12332
  *
12230
12333
  * By Richard Davey http://www.photonstorm.com @photonstorm
12231
12334
  *
@@ -12268,7 +12371,7 @@ PIXI.AbstractFilter.prototype.apply = function(frameBuffer)
12268
12371
  */
12269
12372
  var Phaser = Phaser || {
12270
12373
 
12271
- VERSION: '2.2.1',
12374
+ VERSION: '2.2.2',
12272
12375
  GAMES: [],
12273
12376
 
12274
12377
  AUTO: 0,
@@ -13727,19 +13830,6 @@ Phaser.Point.prototype = {
13727
13830
 
13728
13831
  },
13729
13832
 
13730
- /**
13731
- * Returns the angle squared between this Point object and another object with public x and y properties.
13732
- *
13733
- * @method Phaser.Point#angleSq
13734
- * @param {Phaser.Point|any} a - The object to get the angleSq from this Point to.
13735
- * @return {number} The angleSq between the two objects.
13736
- */
13737
- angleSq: function (a) {
13738
-
13739
- return this.subtract(a).angle(a.subtract(this));
13740
-
13741
- },
13742
-
13743
13833
  /**
13744
13834
  * Rotates this Point around the x/y coordinates given to the desired angle.
13745
13835
  *
@@ -14036,20 +14126,6 @@ Phaser.Point.angle = function (a, b) {
14036
14126
 
14037
14127
  };
14038
14128
 
14039
- /**
14040
- * Returns the angle squared between two Point objects.
14041
- *
14042
- * @method Phaser.Point.angleSq
14043
- * @param {Phaser.Point} a - The first Point object.
14044
- * @param {Phaser.Point} b - The second Point object.
14045
- * @return {number} The angle squared between the two Points.
14046
- */
14047
- Phaser.Point.angleSq = function (a, b) {
14048
-
14049
- return a.subtract(b).angle(b.subtract(a));
14050
-
14051
- };
14052
-
14053
14129
  /**
14054
14130
  * Creates a negative Point.
14055
14131
  *
@@ -14135,7 +14211,7 @@ Phaser.Point.rperp = function (a, out) {
14135
14211
  };
14136
14212
 
14137
14213
  /**
14138
- * Returns the distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties).
14214
+ * Returns the euclidian distance of this Point object to the given object (can be a Circle, Point or anything with x/y properties).
14139
14215
  *
14140
14216
  * @method Phaser.Point.distance
14141
14217
  * @param {object} a - The target object. Must have visible x and y properties that represent the center of the object.
@@ -14622,16 +14698,16 @@ Phaser.Rectangle.prototype = {
14622
14698
  },
14623
14699
 
14624
14700
  /**
14625
- * Determines whether the two Rectangles intersect with each other.
14626
- * This method checks the x, y, width, and height properties of the Rectangles.
14701
+ * Determines whether this Rectangle and another given Rectangle intersect with each other.
14702
+ * This method checks the x, y, width, and height properties of the two Rectangles.
14703
+ *
14627
14704
  * @method Phaser.Rectangle#intersects
14628
14705
  * @param {Phaser.Rectangle} b - The second Rectangle object.
14629
- * @param {number} tolerance - A tolerance value to allow for an intersection test with padding, default to 0.
14630
14706
  * @return {boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false.
14631
14707
  */
14632
- intersects: function (b, tolerance) {
14708
+ intersects: function (b) {
14633
14709
 
14634
- return Phaser.Rectangle.intersects(this, b, tolerance);
14710
+ return Phaser.Rectangle.intersects(this, b);
14635
14711
 
14636
14712
  },
14637
14713
 
@@ -15303,6 +15379,7 @@ Phaser.Line.prototype = {
15303
15379
 
15304
15380
  /**
15305
15381
  * Sets the components of the Line to the specified values.
15382
+ *
15306
15383
  * @method Phaser.Line#setTo
15307
15384
  * @param {number} [x1=0] - The x coordinate of the start of the line.
15308
15385
  * @param {number} [y1=0] - The y coordinate of the start of the line.
@@ -15322,6 +15399,7 @@ Phaser.Line.prototype = {
15322
15399
  /**
15323
15400
  * Sets the line to match the x/y coordinates of the two given sprites.
15324
15401
  * Can optionally be calculated from their center coordinates.
15402
+ *
15325
15403
  * @method Phaser.Line#fromSprite
15326
15404
  * @param {Phaser.Sprite} startSprite - The coordinates of this Sprite will be set to the Line.start point.
15327
15405
  * @param {Phaser.Sprite} endSprite - The coordinates of this Sprite will be set to the Line.start point.
@@ -15341,6 +15419,25 @@ Phaser.Line.prototype = {
15341
15419
 
15342
15420
  },
15343
15421
 
15422
+ /**
15423
+ * Sets this line to start at the given `x` and `y` coordinates and for the segment to extend at `angle` for the given `length`.
15424
+ *
15425
+ * @method Phaser.Line#fromAngle
15426
+ * @param {number} x - The x coordinate of the start of the line.
15427
+ * @param {number} y - The y coordinate of the start of the line.
15428
+ * @param {number} angle - The angle of the line in radians.
15429
+ * @param {number} length - The length of the line in pixels.
15430
+ * @return {Phaser.Line} This line object
15431
+ */
15432
+ fromAngle: function (x, y, angle, length) {
15433
+
15434
+ this.start.setTo(x, y);
15435
+ this.end.setTo(x + (Math.cos(angle) * length), y + (Math.sin(angle) * length));
15436
+
15437
+ return this;
15438
+
15439
+ },
15440
+
15344
15441
  /**
15345
15442
  * Checks for intersection between this line and another Line.
15346
15443
  * If asSegment is true it will check for segment intersection. If asSegment is false it will check for line intersection.
@@ -15358,8 +15455,23 @@ Phaser.Line.prototype = {
15358
15455
 
15359
15456
  },
15360
15457
 
15458
+ /**
15459
+ * Returns the reflected angle between two lines.
15460
+ * This is the outgoing angle based on the angle of this line and the normalAngle of the given line.
15461
+ *
15462
+ * @method Phaser.Line#reflect
15463
+ * @param {Phaser.Line} line - The line to reflect off this line.
15464
+ * @return {number} The reflected angle in radians.
15465
+ */
15466
+ reflect: function (line) {
15467
+
15468
+ return Phaser.Line.reflect(this, line);
15469
+
15470
+ },
15471
+
15361
15472
  /**
15362
15473
  * Tests if the given coordinates fall on this line. See pointOnSegment to test against just the line segment.
15474
+ *
15363
15475
  * @method Phaser.Line#pointOnLine
15364
15476
  * @param {number} x - The line to check against this one.
15365
15477
  * @param {number} y - The line to check against this one.
@@ -15373,6 +15485,7 @@ Phaser.Line.prototype = {
15373
15485
 
15374
15486
  /**
15375
15487
  * Tests if the given coordinates fall on this line and within the segment. See pointOnLine to test against just the line.
15488
+ *
15376
15489
  * @method Phaser.Line#pointOnSegment
15377
15490
  * @param {number} x - The line to check against this one.
15378
15491
  * @param {number} y - The line to check against this one.
@@ -15626,6 +15739,45 @@ Object.defineProperty(Phaser.Line.prototype, "height", {
15626
15739
 
15627
15740
  });
15628
15741
 
15742
+ /**
15743
+ * @name Phaser.Line#normalX
15744
+ * @property {number} normalX - Gets the x component of the left-hand normal of this line.
15745
+ * @readonly
15746
+ */
15747
+ Object.defineProperty(Phaser.Line.prototype, "normalX", {
15748
+
15749
+ get: function () {
15750
+ return Math.cos(this.angle - 1.5707963267948966);
15751
+ }
15752
+
15753
+ });
15754
+
15755
+ /**
15756
+ * @name Phaser.Line#normalY
15757
+ * @property {number} normalY - Gets the y component of the left-hand normal of this line.
15758
+ * @readonly
15759
+ */
15760
+ Object.defineProperty(Phaser.Line.prototype, "normalY", {
15761
+
15762
+ get: function () {
15763
+ return Math.sin(this.angle - 1.5707963267948966);
15764
+ }
15765
+
15766
+ });
15767
+
15768
+ /**
15769
+ * @name Phaser.Line#normalAngle
15770
+ * @property {number} normalAngle - Gets the angle in radians of the normal of this line (line.angle - 90 degrees.)
15771
+ * @readonly
15772
+ */
15773
+ Object.defineProperty(Phaser.Line.prototype, "normalAngle", {
15774
+
15775
+ get: function () {
15776
+ return Phaser.Math.wrap(this.angle - 1.5707963267948966, -Math.PI, Math.PI);
15777
+ }
15778
+
15779
+ });
15780
+
15629
15781
  /**
15630
15782
  * Checks for intersection between two lines as defined by the given start and end points.
15631
15783
  * If asSegment is true it will check for line segment intersection. If asSegment is false it will check for line intersection.
@@ -15638,7 +15790,7 @@ Object.defineProperty(Phaser.Line.prototype, "height", {
15638
15790
  * @param {Phaser.Point} e - The start of the second Line to be checked.
15639
15791
  * @param {Phaser.Point} f - The end of the second line to be checked.
15640
15792
  * @param {boolean} [asSegment=true] - If true it will check for segment intersection, otherwise full line intersection.
15641
- * @param {Phaser.Point} [result] - A Point object to store the result in, if not given a new one will be created.
15793
+ * @param {Phaser.Point|object} [result] - A Point object to store the result in, if not given a new one will be created.
15642
15794
  * @return {Phaser.Point} The intersection segment of the two lines as a Point, or null if there is no intersection.
15643
15795
  */
15644
15796
  Phaser.Line.intersectsPoints = function (a, b, e, f, asSegment, result) {
@@ -15664,12 +15816,16 @@ Phaser.Line.intersectsPoints = function (a, b, e, f, asSegment, result) {
15664
15816
 
15665
15817
  if (asSegment)
15666
15818
  {
15667
- var uc = ((f.y-e.y)*(b.x-a.x) - (f.x-e.x)*(b.y- a.y));
15668
- var ua = (((f.x-e.x)*(a.y-e.y)) - (f.y-e.y)*(a.x-e.x)) / uc;
15669
- var ub = (((b.x- a.x)*(a.y- e.y)) - ((b.y-a.y)*(a.x- e.x))) / uc;
15670
- if (ua >=0 && ua<=1 && ub >=0 && ub <=1) {
15819
+ var uc = ((f.y - e.y) * (b.x - a.x) - (f.x - e.x) * (b.y - a.y));
15820
+ var ua = (((f.x - e.x) * (a.y - e.y)) - (f.y - e.y) * (a.x - e.x)) / uc;
15821
+ var ub = (((b.x - a.x) * (a.y - e.y)) - ((b.y - a.y) * (a.x - e.x))) / uc;
15822
+
15823
+ if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1)
15824
+ {
15671
15825
  return result;
15672
- } else {
15826
+ }
15827
+ else
15828
+ {
15673
15829
  return null;
15674
15830
  }
15675
15831
  }
@@ -15698,6 +15854,21 @@ Phaser.Line.intersects = function (a, b, asSegment, result) {
15698
15854
 
15699
15855
  };
15700
15856
 
15857
+ /**
15858
+ * Returns the reflected angle between two lines.
15859
+ * This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2.
15860
+ *
15861
+ * @method Phaser.Line.reflect
15862
+ * @param {Phaser.Line} a - The base line.
15863
+ * @param {Phaser.Line} b - The line to be reflected from the base line.
15864
+ * @return {number} The reflected angle in radians.
15865
+ */
15866
+ Phaser.Line.reflect = function (a, b) {
15867
+
15868
+ return 2 * b.normalAngle - 3.141592653589793 - a.angle;
15869
+
15870
+ };
15871
+
15701
15872
  /**
15702
15873
  * @author Richard Davey <rich@photonstorm.com>
15703
15874
  * @author Chad Engler <chad@pantherdev.com>
@@ -15770,8 +15941,9 @@ Phaser.Ellipse.prototype = {
15770
15941
 
15771
15942
  /**
15772
15943
  * Returns the framing rectangle of the ellipse as a Phaser.Rectangle object.
15944
+ *
15773
15945
  * @method Phaser.Ellipse#getBounds
15774
- * @return {Phaser.Rectangle} The bounds of the Circle.
15946
+ * @return {Phaser.Rectangle} The bounds of the Ellipse.
15775
15947
  */
15776
15948
  getBounds: function () {
15777
15949
 
@@ -15781,6 +15953,7 @@ Phaser.Ellipse.prototype = {
15781
15953
 
15782
15954
  /**
15783
15955
  * Copies the x, y, width and height properties from any given object to this Ellipse.
15956
+ *
15784
15957
  * @method Phaser.Ellipse#copyFrom
15785
15958
  * @param {any} source - The object to copy from.
15786
15959
  * @return {Phaser.Ellipse} This Ellipse object.
@@ -15893,7 +16066,7 @@ Object.defineProperty(Phaser.Ellipse.prototype, "right", {
15893
16066
  }
15894
16067
  else
15895
16068
  {
15896
- this.width = this.x + value;
16069
+ this.width = value - this.x;
15897
16070
  }
15898
16071
  }
15899
16072
 
@@ -15935,7 +16108,7 @@ Object.defineProperty(Phaser.Ellipse.prototype, "bottom", {
15935
16108
  }
15936
16109
  else
15937
16110
  {
15938
- this.height = this.y + value;
16111
+ this.height = value - this.y;
15939
16112
  }
15940
16113
  }
15941
16114
 
@@ -15966,6 +16139,7 @@ Object.defineProperty(Phaser.Ellipse.prototype, "empty", {
15966
16139
 
15967
16140
  /**
15968
16141
  * Return true if the given x/y coordinates are within the Ellipse object.
16142
+ *
15969
16143
  * @method Phaser.Ellipse.contains
15970
16144
  * @param {Phaser.Ellipse} a - The Ellipse to be checked.
15971
16145
  * @param {number} x - The X value of the coordinate to test.
@@ -15979,26 +16153,14 @@ Phaser.Ellipse.contains = function (a, x, y) {
15979
16153
  return false;
15980
16154
  }
15981
16155
 
15982
- // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5
15983
- var normx = ((x - a.x) / a.width) - 0.5;
15984
- var normy = ((y - a.y) / a.height) - 0.5;
16156
+ // Normalize the coords to an ellipse with center 0,0
16157
+ var normx = ((x - a.x) / a.width);
16158
+ var normy = ((y - a.y) / a.height);
15985
16159
 
15986
16160
  normx *= normx;
15987
16161
  normy *= normy;
15988
16162
 
15989
- return (normx + normy < 0.25);
15990
-
15991
- };
15992
-
15993
- /**
15994
- * Returns the framing rectangle of the ellipse as a Phaser.Rectangle object.
15995
- *
15996
- * @method Phaser.Ellipse.getBounds
15997
- * @return {Phaser.Rectangle} The framing rectangle
15998
- */
15999
- Phaser.Ellipse.prototype.getBounds = function() {
16000
-
16001
- return new Phaser.Rectangle(this.x, this.y, this.width, this.height);
16163
+ return (normx + normy <= 1);
16002
16164
 
16003
16165
  };
16004
16166
 
@@ -18005,6 +18167,16 @@ Phaser.State = function () {
18005
18167
 
18006
18168
  Phaser.State.prototype = {
18007
18169
 
18170
+ /**
18171
+ * init is the very first function called when your State starts up. It's called before preload, create or anything else.
18172
+ * If you need to route the game away to another State you could do so here, or if you need to prepare a set of variables
18173
+ * or objects before the preloading starts.
18174
+ *
18175
+ * @method Phaser.State#init
18176
+ */
18177
+ init: function () {
18178
+ },
18179
+
18008
18180
  /**
18009
18181
  * preload is called first. Normally you'd use this to load your game assets (or those needed for the current State)
18010
18182
  * You shouldn't create any objects in this method that require assets that you're also loading in this method, as
@@ -20253,6 +20425,23 @@ Phaser.Stage.prototype.postUpdate = function () {
20253
20425
 
20254
20426
  };
20255
20427
 
20428
+ /**
20429
+ * Updates the transforms for all objects on the display list.
20430
+ * This overrides the Pixi default as we don't need the interactionManager, but do need the game property check.
20431
+ *
20432
+ * @method Phaser.Stage#updateTransform
20433
+ */
20434
+ Phaser.Stage.prototype.updateTransform = function () {
20435
+
20436
+ this.worldAlpha = 1;
20437
+
20438
+ for (var i = 0, j = this.children.length; i < j; i++)
20439
+ {
20440
+ this.children[i].updateTransform();
20441
+ }
20442
+
20443
+ };
20444
+
20256
20445
  /**
20257
20446
  * Starts a page visibility event listener running, or window.blur/focus if not supported by the browser.
20258
20447
  * @method Phaser.Stage#checkVisibility
@@ -21130,24 +21319,23 @@ Phaser.Group.prototype.replace = function (oldChild, newChild) {
21130
21319
 
21131
21320
  if (index !== -1)
21132
21321
  {
21133
- if (newChild.parent !== undefined)
21322
+ if (newChild.parent)
21134
21323
  {
21135
- newChild.events.onRemovedFromGroup$dispatch(newChild, this);
21136
- newChild.parent.removeChild(newChild);
21137
-
21138
21324
  if (newChild.parent instanceof Phaser.Group)
21139
21325
  {
21140
- newChild.parent.updateZ();
21326
+ newChild.parent.remove(newChild);
21327
+ }
21328
+ else
21329
+ {
21330
+ newChild.parent.removeChild(newChild);
21141
21331
  }
21142
21332
  }
21143
21333
 
21144
- var temp = oldChild;
21145
-
21146
- this.remove(temp);
21334
+ this.remove(oldChild);
21147
21335
 
21148
21336
  this.addAt(newChild, index);
21149
21337
 
21150
- return temp;
21338
+ return oldChild;
21151
21339
  }
21152
21340
 
21153
21341
  };
@@ -23307,8 +23495,8 @@ Phaser.FlexLayer.prototype.debug = function () {
23307
23495
  * dimenstions of the Display canvas's Parent container/element - the _effective CSS rules of the
23308
23496
  * canvas's Parent element play an important role_ in the operation of the ScaleManager.
23309
23497
  *
23310
- * The Display canvas - or Game size, depending {@link Phaser.ScaleManager#scaleMode scaleMode} - is updated to best utilize the Parent size.
23311
- * When in Fullscreen mode or with `parentIsWindow` the Parent size is that of the visual viewport (see {@link Phaser.ScaleManager#getParentBounds getParentBounds}).
23498
+ * The Display canvas - or Game size, depending {@link #scaleMode} - is updated to best utilize the Parent size.
23499
+ * When in Fullscreen mode or with {@link #parentIsWindow} the Parent size is that of the visual viewport (see {@link Phaser.ScaleManager#getParentBounds getParentBounds}).
23312
23500
  *
23313
23501
  * Parent and Display canvas containment guidelines:
23314
23502
  *
@@ -23319,6 +23507,8 @@ Phaser.FlexLayer.prototype.debug = function () {
23319
23507
  *
23320
23508
  * - The Parent element should _not_ apply a padding as this is not accounted for.
23321
23509
  * If a padding is required apply it to the Parent's parent or apply a margin to the Parent.
23510
+ * If you need to add a border, margin or any other CSS around your game container, then use a parent element and
23511
+ * apply the CSS to this instead, otherwise you'll be constantly resizing the shape of the game container.
23322
23512
  *
23323
23513
  * - The Display canvas layout CSS styles (ie. margins, size) should not be altered/specified as
23324
23514
  * they may be updated by the ScaleManager.
@@ -23374,8 +23564,8 @@ Phaser.ScaleManager = function (game, width, height) {
23374
23564
 
23375
23565
  /**
23376
23566
  * Minimum width the canvas should be scaled to (in pixels).
23377
- * Change with `setMinMax`.
23378
- * @property {number} minWidth
23567
+ * Change with {@link #setMinMax}.
23568
+ * @property {?number} minWidth
23379
23569
  * @readonly
23380
23570
  * @protected
23381
23571
  */
@@ -23384,8 +23574,8 @@ Phaser.ScaleManager = function (game, width, height) {
23384
23574
  /**
23385
23575
  * Maximum width the canvas should be scaled to (in pixels).
23386
23576
  * If null it will scale to whatever width the browser can handle.
23387
- * Change with `setMinMax`.
23388
- * @property {number} maxWidth
23577
+ * Change with {@link #setMinMax}.
23578
+ * @property {?number} maxWidth
23389
23579
  * @readonly
23390
23580
  * @protected
23391
23581
  */
@@ -23393,8 +23583,8 @@ Phaser.ScaleManager = function (game, width, height) {
23393
23583
 
23394
23584
  /**
23395
23585
  * Minimum height the canvas should be scaled to (in pixels).
23396
- * Change with `setMinMax`.
23397
- * @property {number} minHeight
23586
+ * Change with {@link #setMinMax}.
23587
+ * @property {?number} minHeight
23398
23588
  * @readonly
23399
23589
  * @protected
23400
23590
  */
@@ -23403,8 +23593,8 @@ Phaser.ScaleManager = function (game, width, height) {
23403
23593
  /**
23404
23594
  * Maximum height the canvas should be scaled to (in pixels).
23405
23595
  * If null it will scale to whatever height the browser can handle.
23406
- * Change with `setMinMax`.
23407
- * @property {number} maxHeight
23596
+ * Change with {@link #setMinMax}.
23597
+ * @property {?number} maxHeight
23408
23598
  * @readonly
23409
23599
  * @protected
23410
23600
  */
@@ -23421,7 +23611,7 @@ Phaser.ScaleManager = function (game, width, height) {
23421
23611
 
23422
23612
  /**
23423
23613
  * If true, the game should only run in a landscape orientation.
23424
- * Change with `forceOrientation`.
23614
+ * Change with {@link #forceOrientation}.
23425
23615
  * @property {boolean} forceLandscape
23426
23616
  * @readonly
23427
23617
  * @default
@@ -23431,7 +23621,7 @@ Phaser.ScaleManager = function (game, width, height) {
23431
23621
 
23432
23622
  /**
23433
23623
  * If true, the game should only run in a portrait
23434
- * Change with `forceOrientation`.
23624
+ * Change with {@link #forceOrientation}.
23435
23625
  * @property {boolean} forcePortrait
23436
23626
  * @readonly
23437
23627
  * @default
@@ -23440,7 +23630,7 @@ Phaser.ScaleManager = function (game, width, height) {
23440
23630
  this.forcePortrait = false;
23441
23631
 
23442
23632
  /**
23443
- * True if the `forceLandscape` or `forcePortrait` are set and do not agree with the browser orientation.
23633
+ * True if {@link #forceLandscape} or {@link #forcePortrait} are set and do not agree with the browser orientation.
23444
23634
  *
23445
23635
  * This value is not updated immediately.
23446
23636
  *
@@ -23451,14 +23641,14 @@ Phaser.ScaleManager = function (game, width, height) {
23451
23641
  this.incorrectOrientation = false;
23452
23642
 
23453
23643
  /**
23454
- * See `pageAlignHorizontally`.
23644
+ * See {@link #pageAlignHorizontally}.
23455
23645
  * @property {boolean} _pageAlignHorizontally
23456
23646
  * @private
23457
23647
  */
23458
23648
  this._pageAlignHorizontally = false;
23459
23649
 
23460
23650
  /**
23461
- * See `pageAlignVertically`.
23651
+ * See {@link #pageAlignVertically}.
23462
23652
  * @property {boolean} _pageAlignVertically
23463
23653
  * @private
23464
23654
  */
@@ -23489,7 +23679,7 @@ Phaser.ScaleManager = function (game, width, height) {
23489
23679
  * // The orientation just became incorrect:
23490
23680
  * scale.incorrectOrientation && !wasIncorrect
23491
23681
  *
23492
- * It is possible that this signal is triggered after `forceOrientation` so the orientation
23682
+ * It is possible that this signal is triggered after {@link #forceOrientation} so the orientation
23493
23683
  * correctness changes even if the orientation itself does not change.
23494
23684
  *
23495
23685
  * This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused.
@@ -23522,7 +23712,7 @@ Phaser.ScaleManager = function (game, width, height) {
23522
23712
  this.enterPortrait = new Phaser.Signal();
23523
23713
 
23524
23714
  /**
23525
- * This signal is dispatched when the browser enters an incorrect orientation, as defined by `forceOrientation`.
23715
+ * This signal is dispatched when the browser enters an incorrect orientation, as defined by {@link #forceOrientation}.
23526
23716
  *
23527
23717
  * This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused.
23528
23718
  *
@@ -23532,7 +23722,7 @@ Phaser.ScaleManager = function (game, width, height) {
23532
23722
  this.enterIncorrectOrientation = new Phaser.Signal();
23533
23723
 
23534
23724
  /**
23535
- * This signal is dispatched when the browser leaves an incorrect orientation, as defined by `forceOrientation`.
23725
+ * This signal is dispatched when the browser leaves an incorrect orientation, as defined by {@link #forceOrientation}.
23536
23726
  *
23537
23727
  * This is signaled from `preUpdate` (or `pauseUpdate`) _even when_ the game is paused.
23538
23728
  *
@@ -23557,8 +23747,8 @@ Phaser.ScaleManager = function (game, width, height) {
23557
23747
  this.fullScreenTarget = null;
23558
23748
 
23559
23749
  /**
23560
- * The fullscreen target, as created by `createFullScreenTarget`.
23561
- * This is not set if `fullScreenTarget` is used and is cleared when fullscreen mode ends.
23750
+ * The fullscreen target, as created by {@link #createFullScreenTarget}.
23751
+ * This is not set if {@link #fullScreenTarget} is used and is cleared when fullscreen mode ends.
23562
23752
  * @property {?DOMElement} _createdFullScreenTarget
23563
23753
  * @private
23564
23754
  */
@@ -23570,12 +23760,12 @@ Phaser.ScaleManager = function (game, width, height) {
23570
23760
  *
23571
23761
  * The signal is passed two arguments: `scale` (the ScaleManager), and an object in the form `{targetElement: DOMElement}`.
23572
23762
  *
23573
- * The `targetElement` is the {@link Phaser.ScaleManager#fullScreenTarget fullScreenTarget} element,
23574
- * if such is assigned, or a new element created by {@link Phaser.ScaleManager#createFullScreenTarget createFullScreenTarget}.
23763
+ * The `targetElement` is the {@link #fullScreenTarget} element,
23764
+ * if such is assigned, or a new element created by {@link #createFullScreenTarget}.
23575
23765
  *
23576
23766
  * Custom CSS styling or resets can be applied to `targetElement` as required.
23577
23767
  *
23578
- * If `targetElement` is _not_ the same element as {@link Phaser.ScaleManager.fullScreenTarget}:
23768
+ * If `targetElement` is _not_ the same element as {@link #fullScreenTarget}:
23579
23769
  * - After initialization the Display canvas is moved onto the `targetElement` for
23580
23770
  * the duration of the fullscreen mode, and restored to it's original DOM location when fullscreen is exited.
23581
23771
  * - The `targetElement` is moved/reparanted within the DOM and may have its CSS styles updated.
@@ -23629,7 +23819,7 @@ Phaser.ScaleManager = function (game, width, height) {
23629
23819
 
23630
23820
  /**
23631
23821
  * This signal is dispatched when the browser fails to enter fullscreen mode;
23632
- * or if the device does not support fullscreen mode and `startFullScreen` is invoked.
23822
+ * or if the device does not support fullscreen mode and {@link #startFullScreen} is invoked.
23633
23823
  *
23634
23824
  * @property {Phaser.Signal} fullScreenFailed
23635
23825
  * @public
@@ -23720,7 +23910,10 @@ Phaser.ScaleManager = function (game, width, height) {
23720
23910
 
23721
23911
  /**
23722
23912
  * Various compatibility settings.
23723
- * The `(auto)` value indicates the setting is configured based on device and runtime information.
23913
+ * A value of "(auto)" indicates the setting is configured based on device and runtime information.
23914
+ *
23915
+ * A {@link #refresh} may need to be peformed after making changes.
23916
+ *
23724
23917
  * @protected
23725
23918
  *
23726
23919
  * @property {boolean} [supportsFullscreen=(auto)] - True only if fullscreen support will be used. (Changing to fullscreen still might not work.)
@@ -23732,8 +23925,14 @@ Phaser.ScaleManager = function (game, width, height) {
23732
23925
  * @property {?Phaser.Point} [scrollTo=(auto)] - If specified the window will be scrolled to this position on every refresh.
23733
23926
  *
23734
23927
  * @property {boolean} [forceMinimumDocumentHeight=false] - If enabled the document elements minimum height is explicity set on updates.
23928
+ * The height set varies by device and may either be the height of the window or the viewport.
23735
23929
  *
23736
23930
  * @property {boolean} [canExpandParent=true] - If enabled then SHOW_ALL and USER_SCALE modes can try and expand the parent element. It may be necessary for the parent element to impose CSS width/height restrictions.
23931
+ *
23932
+ * @property {string} [clickTrampoline=(auto)] - On certain browsers (eg. IE) FullScreen events need to be triggered via 'click' events.
23933
+ * A value of 'when-not-mouse' uses a click trampoline when a pointer that is not the primary mouse is used.
23934
+ * Any other string value (including the empty string) prevents using click trampolines.
23935
+ * For more details on click trampolines see {@link Phaser.Pointer#addClickTrampoline}.
23737
23936
  */
23738
23937
  this.compatibility = {
23739
23938
  supportsFullScreen: false,
@@ -23741,7 +23940,8 @@ Phaser.ScaleManager = function (game, width, height) {
23741
23940
  noMargins: false,
23742
23941
  scrollTo: null,
23743
23942
  forceMinimumDocumentHeight: false,
23744
- canExpandParent: true
23943
+ canExpandParent: true,
23944
+ clickTrampoline: ''
23745
23945
  };
23746
23946
 
23747
23947
  /**
@@ -23759,18 +23959,22 @@ Phaser.ScaleManager = function (game, width, height) {
23759
23959
  this._fullScreenScaleMode = Phaser.ScaleManager.NO_SCALE;
23760
23960
 
23761
23961
  /**
23762
- * If the parent container of the game is the browser window (ie. document.body), rather than a div, this should set to `true`.
23962
+ * If the parent container of the Game canvas is the browser window itself (ie. document.body),
23963
+ * rather than another div, this should set to `true`.
23964
+ *
23965
+ * The {@link #parentNode} property is generally ignored while this is in effect.
23966
+ *
23763
23967
  * @property {boolean} parentIsWindow
23764
- * @readonly
23765
23968
  */
23766
23969
  this.parentIsWindow = false;
23767
23970
 
23768
23971
  /**
23769
23972
  * The _original_ DOM element for the parent of the Display canvas.
23770
- * This may be different in fullscreen - see `createFullScreenTarget`.
23973
+ * This may be different in fullscreen - see {@link #createFullScreenTarget}.
23974
+ *
23975
+ * This should only be changed after moving the Game canvas to a different DOM parent.
23771
23976
  *
23772
23977
  * @property {?DOMElement} parentNode
23773
- * @readonly
23774
23978
  */
23775
23979
  this.parentNode = null;
23776
23980
 
@@ -23817,7 +24021,7 @@ Phaser.ScaleManager = function (game, width, height) {
23817
24021
  this.onResize = null;
23818
24022
 
23819
24023
  /**
23820
- * The context in which the `onResize` callback will be called.
24024
+ * The context in which the {@link #onResize} callback will be called.
23821
24025
  * @property {object} onResizeContext
23822
24026
  * @private
23823
24027
  */
@@ -23831,7 +24035,7 @@ Phaser.ScaleManager = function (game, width, height) {
23831
24035
  this._fullScreenRestore = null;
23832
24036
 
23833
24037
  /**
23834
- * The _actual_ game dimensions, as initially set or set by `setGameSize`.
24038
+ * The _actual_ game dimensions, as initially set or set by {@link #setGameSize}.
23835
24039
  * @property {Phaser.Rectangle} _gameSize
23836
24040
  * @private
23837
24041
  */
@@ -23984,10 +24188,12 @@ Phaser.ScaleManager.prototype = {
23984
24188
  if (this.game.device.desktop)
23985
24189
  {
23986
24190
  compat.orientationFallback = 'screen';
24191
+ compat.clickTrampoline = 'when-not-mouse';
23987
24192
  }
23988
24193
  else
23989
24194
  {
23990
24195
  compat.orientationFallback = '';
24196
+ compat.clickTrampoline = '';
23991
24197
  }
23992
24198
 
23993
24199
  // Configure event listeners
@@ -24222,17 +24428,17 @@ Phaser.ScaleManager.prototype = {
24222
24428
  /**
24223
24429
  * Sets the callback that will be invoked before sizing calculations.
24224
24430
  *
24225
- * This is the appropriate place to call `setUserScale` if needing custom dynamic scaling.
24431
+ * This is the appropriate place to call {@link #setUserScale} if needing custom dynamic scaling.
24226
24432
  *
24227
24433
  * The callback is supplied with two arguments `scale` and `parentBounds` where `scale` is the ScaleManager
24228
24434
  * and `parentBounds`, a Phaser.Rectangle, is the size of the Parent element.
24229
24435
  *
24230
24436
  * This callback
24231
24437
  * - May be invoked even though the parent container or canvas sizes have not changed
24232
- * - Unlike `onSizeChange`, it runs _before_ the canvas is guaranteed to be updated
24438
+ * - Unlike {@link #onSizeChange}, it runs _before_ the canvas is guaranteed to be updated
24233
24439
  * - Will be invoked from `preUpdate`, _even when_ the game is paused
24234
24440
  *
24235
- * See `onSizeChange` for a better way of reacting to layout updates.
24441
+ * See {@link #onSizeChange} for a better way of reacting to layout updates.
24236
24442
  *
24237
24443
  * @method Phaser.ScaleManager#setResizeCallback
24238
24444
  * @public
@@ -24249,7 +24455,7 @@ Phaser.ScaleManager.prototype = {
24249
24455
  /**
24250
24456
  * Signals a resize - IF the canvas or Game size differs from the last signal.
24251
24457
  *
24252
- * This also triggers updates on `grid` (FlexGrid) and, if in a RESIZE mode, `game.state` (StateManager).
24458
+ * This also triggers updates on {@link #grid} (FlexGrid) and, if in a RESIZE mode, `game.state` (StateManager).
24253
24459
  *
24254
24460
  * @method Phaser.ScaleMager#signalSizeChange
24255
24461
  * @private
@@ -24415,7 +24621,7 @@ Phaser.ScaleManager.prototype = {
24415
24621
 
24416
24622
  /**
24417
24623
  * Update relevant scaling values based on the ScaleManager dimension and game dimensions,
24418
- * which should already be set. This does not change `sourceAspectRatio`.
24624
+ * which should already be set. This does not change {@link #sourceAspectRatio}.
24419
24625
  *
24420
24626
  * @method Phaser.ScaleManager#updateScalingAndBounds
24421
24627
  * @private
@@ -24592,18 +24798,19 @@ Phaser.ScaleManager.prototype = {
24592
24798
  },
24593
24799
 
24594
24800
  /**
24595
- * The `refresh` methods informs the ScaleManager that a layout refresh is required.
24801
+ * The "refresh" methods informs the ScaleManager that a layout refresh is required.
24596
24802
  *
24597
24803
  * The ScaleManager automatically queues a layout refresh (eg. updates the Game size or Display canvas layout)
24598
24804
  * when the browser is resized, the orientation changes, or when there is a detected change
24599
24805
  * of the Parent size. Refreshing is also done automatically when public properties,
24600
- * such as `scaleMode`, are updated or state-changing methods are invoked.
24806
+ * such as {@link #scaleMode}, are updated or state-changing methods are invoked.
24601
24807
  *
24602
- * The `refresh` method _may_ need to be used in a few (rare) situtations when
24808
+ * The "refresh" method _may_ need to be used in a few (rare) situtations when
24603
24809
  *
24604
24810
  * - a device change event is not correctly detected; or
24605
24811
  * - the Parent size changes (and an immediate reflow is desired); or
24606
- * - the ScaleManager state is updated by non-standard means.
24812
+ * - the ScaleManager state is updated by non-standard means; or
24813
+ * - certain {@link #compatibility} properties are manually changed.
24607
24814
  *
24608
24815
  * The queued layout refresh is not immediate but will run promptly in an upcoming `preRender`.
24609
24816
  *
@@ -24700,10 +24907,10 @@ Phaser.ScaleManager.prototype = {
24700
24907
  /**
24701
24908
  * Returns the computed Parent size/bounds that the Display canvas is allowed/expected to fill.
24702
24909
  *
24703
- * If in fullscreen mode or without parent (see {@link Phaser.ScaleManager#parentIsWindow parentIsWindow}),
24910
+ * If in fullscreen mode or without parent (see {@link #parentIsWindow}),
24704
24911
  * this will be the bounds of the visual viewport itself.
24705
24912
  *
24706
- * This function takes the `windowConstraints` into consideration - if the parent is partially outside
24913
+ * This function takes the {@link #windowConstraints} into consideration - if the parent is partially outside
24707
24914
  * the viewport then this function may return a smaller than expected size.
24708
24915
  *
24709
24916
  * Values are rounded to the nearest pixel.
@@ -24986,7 +25193,7 @@ Phaser.ScaleManager.prototype = {
24986
25193
 
24987
25194
  /**
24988
25195
  * Updates the width/height such that the game is stretched to the available size.
24989
- * Honors `maxWidth` and `maxHeight` when _not_ in fullscreen.
25196
+ * Honors {@link #maxWidth} and {@link #maxHeight} when _not_ in fullscreen.
24990
25197
  *
24991
25198
  * @method Phaser.ScaleManager#setExactFit
24992
25199
  * @private
@@ -25018,9 +25225,9 @@ Phaser.ScaleManager.prototype = {
25018
25225
 
25019
25226
  /**
25020
25227
  * Creates a fullscreen target. This is called automatically as as needed when entering
25021
- * fullscreen mode and the resulting element is supplied to `onFullScreenInit`.
25228
+ * fullscreen mode and the resulting element is supplied to {@link #onFullScreenInit}.
25022
25229
  *
25023
- * Use {@link Phaser.ScaleManager#onFullScreenInit onFullScreenInit} to customize the created object.
25230
+ * Use {@link #onFullScreenInit} to customize the created object.
25024
25231
  *
25025
25232
  * @method Phaser.ScaleManager#createFullScreenTarget
25026
25233
  * @protected
@@ -25041,10 +25248,10 @@ Phaser.ScaleManager.prototype = {
25041
25248
  * Start the browsers fullscreen mode - this _must_ be called from a user input Pointer or Mouse event.
25042
25249
  *
25043
25250
  * The Fullscreen API must be supported by the browser for this to work - it is not the same as setting
25044
- * the game size to fill the browser window. See `compatibility.supportsFullScreen` to check if the current
25251
+ * the game size to fill the browser window. See {@link Phaser.ScaleManager#compatibility compatibility.supportsFullScreen} to check if the current
25045
25252
  * device is reported to support fullscreen mode.
25046
25253
  *
25047
- * The `fullScreenFailed` signal will be dispatched if the fullscreen change request failed or the game does not support the Fullscreen API.
25254
+ * The {@link #fullScreenFailed} signal will be dispatched if the fullscreen change request failed or the game does not support the Fullscreen API.
25048
25255
  *
25049
25256
  * @method Phaser.ScaleManager#startFullScreen
25050
25257
  * @public
@@ -25069,13 +25276,17 @@ Phaser.ScaleManager.prototype = {
25069
25276
  return;
25070
25277
  }
25071
25278
 
25072
- // IE11 clicks trigger MSPointer which is not the mousePointer
25073
- var input = this.game.input;
25074
-
25075
- if (input.activePointer !== input.mousePointer && (allowTrampoline || allowTrampoline !== false))
25279
+ if (this.compatibility.clickTrampoline === 'when-not-mouse')
25076
25280
  {
25077
- input.activePointer.addClickTrampoline("startFullScreen", this.startFullScreen, this, [antialias, false]);
25078
- return;
25281
+ var input = this.game.input;
25282
+
25283
+ if (input.activePointer &&
25284
+ input.activePointer !== input.mousePointer &&
25285
+ (allowTrampoline || allowTrampoline !== false))
25286
+ {
25287
+ input.activePointer.addClickTrampoline("startFullScreen", this.startFullScreen, this, [antialias, false]);
25288
+ return;
25289
+ }
25079
25290
  }
25080
25291
 
25081
25292
  if (typeof antialias !== 'undefined' && this.game.renderType === Phaser.CANVAS)
@@ -25413,7 +25624,8 @@ Phaser.ScaleManager.prototype.setScreenSize = Phaser.ScaleManager.prototype.upda
25413
25624
  Phaser.ScaleManager.prototype.setSize = Phaser.ScaleManager.prototype.reflowCanvas;
25414
25625
 
25415
25626
  /**
25416
- * Checks if the browser is in the correct orientation for the game, dependent upon `forceLandscape` and `forcePortrait`, and updates the state.
25627
+ * Checks if the browser is in the correct orientation for the game,
25628
+ * dependent upon {@link #forceLandscape} and {@link #forcePortrait}, and updates the state.
25417
25629
  *
25418
25630
  * The appropriate event is dispatched if the orientation became valid or invalid.
25419
25631
  *
@@ -25437,7 +25649,7 @@ Phaser.ScaleManager.prototype.checkOrientationState = function () {
25437
25649
  /**
25438
25650
  * The DOM element that is considered the Parent bounding element, if any.
25439
25651
  *
25440
- * This `null` if `parentIsWindow` is true or if fullscreen mode is entered and `fullScreenTarget` is specified.
25652
+ * This `null` if {@link #parentIsWindow} is true or if fullscreen mode is entered and {@link #fullScreenTarget} is specified.
25441
25653
  * It will also be null if there is no game canvas or if the game canvas has no parent.
25442
25654
  *
25443
25655
  * @name Phaser.ScaleManager#boundingParent
@@ -25482,7 +25694,7 @@ Object.defineProperty(Phaser.ScaleManager.prototype, "boundingParent", {
25482
25694
  * The dimensions of the game display area are changed to match the size of the parent container.
25483
25695
  * That is, this mode _changes the Game size_ to match the display size.
25484
25696
  * <p>
25485
- * Any manually set Game size (see `setGameSize`) is ignored while in effect.
25697
+ * Any manually set Game size (see {@link #setGameSize}) is ignored while in effect.
25486
25698
  * </dd>
25487
25699
  * <dt>{@link Phaser.ScaleManager.USER_SCALE}</dt>
25488
25700
  * <dd>
@@ -25585,12 +25797,12 @@ Object.defineProperty(Phaser.ScaleManager.prototype, "currentScaleMode", {
25585
25797
  });
25586
25798
 
25587
25799
  /**
25588
- * If true then the Display canvas will be horizontally-aligned _in the parent container_.
25800
+ * When enabled the Display canvas will be horizontally-aligned _in the Parent container_ (or {@link Phaser.ScaleManager#parentIsWindow window}).
25589
25801
  *
25590
- * To align across the page the Display canvas should be added directly to page;
25591
- * or the parent container should itself be aligned.
25802
+ * To align horizontally across the page the Display canvas should be added directly to page;
25803
+ * or the parent container should itself be horizontally aligned.
25592
25804
  *
25593
- * This is not applicable for the `RESIZE` scaling mode.
25805
+ * Horizontal alignment is not applicable with the {@link .RESIZE} scaling mode.
25594
25806
  *
25595
25807
  * @name Phaser.ScaleManager#pageAlignHorizontally
25596
25808
  * @property {boolean} pageAlignHorizontally
@@ -25617,12 +25829,19 @@ Object.defineProperty(Phaser.ScaleManager.prototype, "pageAlignHorizontally", {
25617
25829
  });
25618
25830
 
25619
25831
  /**
25620
- * If true then the Display canvas will be vertically-aligned _in the parent container_.
25832
+ * When enabled the Display canvas will be vertically-aligned _in the Parent container_ (or {@link Phaser.ScaleManager#parentIsWindow window}).
25833
+ *
25834
+ * To align vertically the Parent element should have a _non-collapsible_ height, such that it will maintain
25835
+ * a height _larger_ than the height of the contained Game canvas - the game canvas will then be scaled vertically
25836
+ * _within_ the remaining available height dictated by the Parent element.
25621
25837
  *
25622
- * To align across the page the Display canvas should be added directly to page;
25623
- * or the parent container should itself be aligned.
25838
+ * One way to prevent the parent from collapsing is to add an absolute "min-height" CSS property to the parent element.
25839
+ * If specifying a relative "min-height/height" or adjusting margins, the Parent height must still be non-collapsible (see note).
25624
25840
  *
25625
- * This is not applicable for the `RESIZE` scaling mode.
25841
+ * _Note_: In version 2.2 the minimum document height is _not_ automatically set to the viewport/window height.
25842
+ * To automatically update the minimum document height set {@link Phaser.ScaleManager#compatibility compatibility.forceMinimumDocumentHeight} to true.
25843
+ *
25844
+ * Vertical alignment is not applicable with the {@link .RESIZE} scaling mode.
25626
25845
  *
25627
25846
  * @name Phaser.ScaleManager#pageAlignVertically
25628
25847
  * @property {boolean} pageAlignVertically
@@ -25700,7 +25919,7 @@ Object.defineProperty(Phaser.ScaleManager.prototype, "isLandscape", {
25700
25919
  * @name Phaser.ScaleManager#orientation
25701
25920
  * @property {integer} orientation
25702
25921
  * @readonly
25703
- * @deprecated 2.2.0 - Use `ScaleManager.screenOrientation` instead.
25922
+ * @deprecated 2.2.0 - Use {@link #screenOrientation} instead.
25704
25923
  */
25705
25924
  Object.defineProperty(Phaser.ScaleManager.prototype, "orientation", {
25706
25925
 
@@ -26418,7 +26637,7 @@ Phaser.Game.prototype = {
26418
26637
 
26419
26638
  this.time.update(time);
26420
26639
 
26421
- // if the logic time is spiralling upwards, skip a frame entirely
26640
+ // if the logic time is spiraling upwards, skip a frame entirely
26422
26641
  if (this._spiralling > 1 && !this.forceSingleUpdate)
26423
26642
  {
26424
26643
  // cause an event to warn the program that this CPU can't keep up with the current desiredFps rate
@@ -26461,7 +26680,11 @@ Phaser.Game.prototype = {
26461
26680
  {
26462
26681
  this._deltaTime -= slowStep;
26463
26682
  this.currentUpdateID = count;
26683
+
26464
26684
  this.updateLogic(1.0 / this.time.desiredFps);
26685
+ // Sync the scene graph after _every_ logic update to account for moved game objects
26686
+ this.stage.updateTransform();
26687
+
26465
26688
  count++;
26466
26689
 
26467
26690
  if (this.forceSingleUpdate && count === 1)
@@ -26470,7 +26693,7 @@ Phaser.Game.prototype = {
26470
26693
  }
26471
26694
  }
26472
26695
 
26473
- // detect spiralling (if the catch-up loop isn't fast enough, the number of iterations will increase constantly)
26696
+ // detect spiraling (if the catch-up loop isn't fast enough, the number of iterations will increase constantly)
26474
26697
  if (count > this._lastCount)
26475
26698
  {
26476
26699
  this._spiralling++;
@@ -26532,6 +26755,7 @@ Phaser.Game.prototype = {
26532
26755
  this.state.pauseUpdate();
26533
26756
  this.debug.preUpdate();
26534
26757
  }
26758
+
26535
26759
  },
26536
26760
 
26537
26761
  /**
@@ -28909,7 +29133,8 @@ Phaser.Mouse = function (game) {
28909
29133
  this.mouseDownCallback = null;
28910
29134
 
28911
29135
  /**
28912
- * @property {function} mouseMoveCallback - A callback that can be fired when the mouse is moved while pressed down.
29136
+ * @property {function} mouseMoveCallback - A callback that can be fired when the mouse is moved.
29137
+ * @deprecated Will be removed soon. Please use `Input.addMoveCallback` instead.
28913
29138
  */
28914
29139
  this.mouseMoveCallback = null;
28915
29140
 
@@ -34024,6 +34249,7 @@ Phaser.Events.prototype = {
34024
34249
  if (this._onRemovedFromWorld) { this._onRemovedFromWorld.dispose(); }
34025
34250
  if (this._onKilled) { this._onKilled.dispose(); }
34026
34251
  if (this._onRevived) { this._onRevived.dispose(); }
34252
+ if (this._onEnterBounds) { this._onEnterBounds.dispose(); }
34027
34253
  if (this._onOutOfBounds) { this._onOutOfBounds.dispose(); }
34028
34254
 
34029
34255
  if (this._onInputOver) { this._onInputOver.dispose(); }
@@ -34135,7 +34361,6 @@ Phaser.Events.prototype.constructor = Phaser.Events;
34135
34361
  // and the dispatch method is the same as the event name postfixed with '$dispatch'.
34136
34362
  for (var prop in Phaser.Events.prototype)
34137
34363
  {
34138
-
34139
34364
  if (!Phaser.Events.prototype.hasOwnProperty(prop) ||
34140
34365
  prop.indexOf('on') !== 0 ||
34141
34366
  Phaser.Events.prototype[prop] !== null)
@@ -34143,21 +34368,22 @@ for (var prop in Phaser.Events.prototype)
34143
34368
  continue;
34144
34369
  }
34145
34370
 
34146
- var backing = 'this._' + prop;
34147
- var dispatch = prop + '$dispatch';
34371
+ (function (prop, backing) {
34372
+ 'use strict';
34148
34373
 
34149
- // `new Function(string)` is ugly but it avoids closures and by-string property lookups.
34150
- // Since this is a [near] micro-optimization anyway, might as well go all the way.
34151
- /*jslint evil: true */
34374
+ // The accessor creates a new Signal; and so it should only be used from user-code.
34375
+ Object.defineProperty(Phaser.Events.prototype, prop, {
34376
+ get: function () {
34377
+ return this[backing] || (this[backing] = new Phaser.Signal());
34378
+ }
34379
+ });
34152
34380
 
34153
- // The accessor creates a new Signal (and so it should only be used from user-code.)
34154
- Object.defineProperty(Phaser.Events.prototype, prop, {
34155
- get: new Function("return "+backing+" || ("+backing+" = new Phaser.Signal())")
34156
- });
34381
+ // The dispatcher will only broadcast on an already-created signal; call this internally.
34382
+ Phaser.Events.prototype[prop + '$dispatch'] = function () {
34383
+ return this[backing] ? this[backing].dispatch.apply(this[backing], arguments) : null;
34384
+ };
34157
34385
 
34158
- // The dispatcher will only broadcast on an already-defined signal.
34159
- Phaser.Events.prototype[dispatch] =
34160
- new Function("return "+backing+" ? "+backing+".dispatch.apply("+backing+", arguments) : null");
34386
+ })(prop, '_' + prop);
34161
34387
 
34162
34388
  }
34163
34389
 
@@ -36032,8 +36258,8 @@ Phaser.BitmapData.prototype = {
36032
36258
  * @param {number} [y=0] - The y coordinate representing the top-left of the region to copy from the source image.
36033
36259
  * @param {number} [width] - The width of the region to copy from the source image. If not specified it will use the full source image width.
36034
36260
  * @param {number} [height] - The height of the region to copy from the source image. If not specified it will use the full source image height.
36035
- * @param {number} [tx] - The x coordinate to translate to before drawing. If not specified it will default to the `x` parameter.
36036
- * @param {number} [ty] - The y coordinate to translate to before drawing. If not specified it will default to the `y` parameter.
36261
+ * @param {number} [tx] - The x coordinate to translate to before drawing. If not specified it will default to the `x` parameter. If `null` and `source` is a Display Object, it will default to `source.x`.
36262
+ * @param {number} [ty] - The y coordinate to translate to before drawing. If not specified it will default to the `y` parameter. If `null` and `source` is a Display Object, it will default to `source.y`.
36037
36263
  * @param {number} [newWidth] - The new width of the block being copied. If not specified it will default to the `width` parameter.
36038
36264
  * @param {number} [newHeight] - The new height of the block being copied. If not specified it will default to the `height` parameter.
36039
36265
  * @param {number} [rotate=0] - The angle in radians to rotate the block to before drawing. Rotation takes place around the center by default, but can be changed with the `anchor` parameters.
@@ -36063,6 +36289,9 @@ Phaser.BitmapData.prototype = {
36063
36289
  this._alpha.current = source.alpha;
36064
36290
  this._image = source.texture.baseTexture.source;
36065
36291
 
36292
+ if (typeof tx === 'undefined' || tx === null) { tx = source.x; }
36293
+ if (typeof ty === 'undefined' || ty === null) { ty = source.y; }
36294
+
36066
36295
  if (source.texture.trim)
36067
36296
  {
36068
36297
  // Offset the translation coordinates by the trim amount
@@ -36251,6 +36480,30 @@ Phaser.BitmapData.prototype = {
36251
36480
 
36252
36481
  },
36253
36482
 
36483
+ /**
36484
+ * Draws the immediate children of a Phaser.Group to this BitmapData.
36485
+ * Children are only drawn if they have their `exists` property set to `true`.
36486
+ * The children will be drawn at their `x` and `y` world space coordinates. If this is outside the bounds of the BitmapData they won't be drawn.
36487
+ * When drawing it will take into account the child's rotation, scale and alpha values.
36488
+ * No iteration takes place. Groups nested inside other Groups will not be iterated through.
36489
+ *
36490
+ * @method Phaser.BitmapData#drawGroup
36491
+ * @param {Phaser.Group} group - The Group to draw onto this BitmapData.
36492
+ * @param {number} [blendMode=null] - The composite blend mode that will be used when drawing the Group children. The default is no blend mode at all.
36493
+ * @param {boolean} [roundPx=false] - Should the x and y values be rounded to integers before drawing? This prevents anti-aliasing in some instances.
36494
+ * @return {Phaser.BitmapData} This BitmapData object for method chaining.
36495
+ */
36496
+ drawGroup: function (group, blendMode, roundPx) {
36497
+
36498
+ if (group.total > 0)
36499
+ {
36500
+ group.forEachExists(this.copy, this, null, null, null, null, null, null, null, null, null, null, null, null, null, null, blendMode, roundPx);
36501
+ }
36502
+
36503
+ return this;
36504
+
36505
+ },
36506
+
36254
36507
  /**
36255
36508
  * Sets the shadow properties of this BitmapDatas context which will affect all draw operations made to it.
36256
36509
  * You can cancel an existing shadow by calling this method and passing no parameters.
@@ -43221,6 +43474,22 @@ Phaser.Graphics.prototype.destroy = function(destroyChildren) {
43221
43474
 
43222
43475
  };
43223
43476
 
43477
+ /*
43478
+ * Draws a circle.
43479
+ *
43480
+ * @method Phaser.Graphics.prototype.drawCircle
43481
+ * @param {Number} x - The X coordinate of the center of the circle.
43482
+ * @param {Number} y - The Y coordinate of the center of the circle.
43483
+ * @param {Number} radius - The diameter of the circle.
43484
+ * @return {Phaser.Graphics} This Graphics object.
43485
+ */
43486
+ Phaser.Graphics.prototype.drawCircle = function(x, y, diameter)
43487
+ {
43488
+ this.drawShape(new Phaser.Circle(x, y, diameter));
43489
+
43490
+ return this;
43491
+ };
43492
+
43224
43493
  /*
43225
43494
  * Draws a single {Phaser.Polygon} triangle from a {Phaser.Point} array
43226
43495
  *
@@ -44486,6 +44755,18 @@ Phaser.Device = function () {
44486
44755
  */
44487
44756
  this.canvas = false;
44488
44757
 
44758
+ /**
44759
+ * @property {?boolean} canvasBitBltShift - True if canvas supports a 'copy' bitblt onto itself when the source and destination regions overlap.
44760
+ * @default
44761
+ */
44762
+ this.canvasBitBltShift = null;
44763
+
44764
+ /**
44765
+ * @property {boolean} webGL - Is webGL available?
44766
+ * @default
44767
+ */
44768
+ this.webGL = false;
44769
+
44489
44770
  /**
44490
44771
  * @property {boolean} file - Is file available?
44491
44772
  * @default
@@ -44504,12 +44785,6 @@ Phaser.Device = function () {
44504
44785
  */
44505
44786
  this.localStorage = false;
44506
44787
 
44507
- /**
44508
- * @property {boolean} webGL - Is webGL available?
44509
- * @default
44510
- */
44511
- this.webGL = false;
44512
-
44513
44788
  /**
44514
44789
  * @property {boolean} worker - Is worker available?
44515
44790
  * @default
@@ -44567,7 +44842,7 @@ Phaser.Device = function () {
44567
44842
  this.mspointer = false;
44568
44843
 
44569
44844
  /**
44570
- * @property {string|null} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll'
44845
+ * @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll'
44571
44846
  * @default
44572
44847
  * @protected
44573
44848
  */
@@ -44730,6 +45005,8 @@ Phaser.Device = function () {
44730
45005
  */
44731
45006
  this.iPad = false;
44732
45007
 
45008
+ // Device features
45009
+
44733
45010
  /**
44734
45011
  * @property {number} pixelRatio - PixelRatio of the host device?
44735
45012
  * @default
@@ -44986,16 +45263,9 @@ Phaser.Device._initialize = function () {
44986
45263
 
44987
45264
  device.file = !!window['File'] && !!window['FileReader'] && !!window['FileList'] && !!window['Blob'];
44988
45265
  device.fileSystem = !!window['requestFileSystem'];
44989
- device.webGL = ( function () { try { var canvas = document.createElement( 'canvas' ); /*Force screencanvas to false*/ canvas.screencanvas = false; return !! window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ); } catch( e ) { return false; } } )();
44990
45266
 
44991
- if (device.webGL === null || device.webGL === false)
44992
- {
44993
- device.webGL = false;
44994
- }
44995
- else
44996
- {
44997
- device.webGL = true;
44998
- }
45267
+ device.webGL = ( function () { try { var canvas = document.createElement( 'canvas' ); /*Force screencanvas to false*/ canvas.screencanvas = false; return !! window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ); } catch( e ) { return false; } } )();
45268
+ device.webGL = !!device.webGL;
44999
45269
 
45000
45270
  device.worker = !!window['Worker'];
45001
45271
 
@@ -45005,6 +45275,22 @@ Phaser.Device._initialize = function () {
45005
45275
 
45006
45276
  device.getUserMedia = !!(navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
45007
45277
 
45278
+ // TODO: replace canvasBitBltShift detection with actual feature check
45279
+
45280
+ // Excludes iOS versions as they generally wrap UIWebView (eg. Safari WebKit) and it
45281
+ // is safer to not try and use the fast copy-over method.
45282
+ if (!device.iOS &&
45283
+ (device.ie || device.firefox || device.chrome))
45284
+ {
45285
+ device.canvasBitBltShift = true;
45286
+ }
45287
+
45288
+ // Known not to work
45289
+ if (device.safari || device.mobileSafari)
45290
+ {
45291
+ device.canvasBitBltShift = false;
45292
+ }
45293
+
45008
45294
  }
45009
45295
 
45010
45296
  /**
@@ -45223,7 +45509,7 @@ Phaser.Device._initialize = function () {
45223
45509
  function _checkAudio () {
45224
45510
 
45225
45511
  device.audioData = !!(window['Audio']);
45226
- device.webAudio = !!(window['webkitAudioContext'] || window['AudioContext']);
45512
+ device.webAudio = !!(window['AudioContext'] || window['webkitAudioContext']);
45227
45513
  var audioElement = document.createElement('audio');
45228
45514
  var result = false;
45229
45515
 
@@ -45832,11 +46118,13 @@ Phaser.Device.whenReady(function (device) {
45832
46118
  if (treatAsDesktop)
45833
46119
  {
45834
46120
 
46121
+ // PST- When scrollbars are not included this causes upstream issues in ScaleManager.
46122
+ // So reverted to the old "include scrollbars."
45835
46123
  var clientWidth = function () {
45836
- return document.documentElement.clientWidth;
46124
+ return Math.max(window.innerWidth, document.documentElement.clientWidth);
45837
46125
  };
45838
46126
  var clientHeight = function () {
45839
- return document.documentElement.clientHeight;
46127
+ return Math.max(window.innerHeight, document.documentElement.clientHeight);
45840
46128
  };
45841
46129
 
45842
46130
  // Interested in area sans-scrollbar
@@ -45945,7 +46233,7 @@ Phaser.Canvas = {
45945
46233
  * @method Phaser.Canvas.create
45946
46234
  * @param {number} [width=256] - The width of the canvas element.
45947
46235
  * @param {number} [height=256] - The height of the canvas element..
45948
- * @param {string} [id=''] - If given this will be set as the ID of the canvas element, otherwise no ID will be set.
46236
+ * @param {string} [id=(none)] - If specified, and not the empty string, this will be set as the ID of the canvas element. Otherwise no ID will be set.
45949
46237
  * @return {HTMLCanvasElement} The newly created canvas element.
45950
46238
  */
45951
46239
  create: function (width, height, id) {
@@ -47459,7 +47747,7 @@ Phaser.Math = {
47459
47747
  },
47460
47748
 
47461
47749
  /**
47462
- * Returns the distance between the two given set of coordinates.
47750
+ * Returns the euclidian distance between the two given set of coordinates.
47463
47751
  *
47464
47752
  * @method Phaser.Math#distance
47465
47753
  * @param {number} x1
@@ -47672,8 +47960,13 @@ Phaser.Math.radToDeg = function radToDeg (radians) {
47672
47960
 
47673
47961
  /**
47674
47962
  * An extremely useful repeatable random data generator.
47963
+ *
47675
47964
  * Based on Nonsense by Josh Faul https://github.com/jocafa/Nonsense.
47676
- * Random number generator from http://baagoe.org/en/wiki/Better_random_numbers_for_javascript
47965
+ *
47966
+ * The random number genererator is based on the Alea PRNG, but is modified.
47967
+ * - https://github.com/coverslide/node-alea
47968
+ * - https://github.com/nquinlan/better-random-numbers-for-javascript-mirror
47969
+ * - http://baagoe.org/en/wiki/Better_random_numbers_for_javascript (original, perm. 404)
47677
47970
  *
47678
47971
  * @class Phaser.RandomDataGenerator
47679
47972
  * @constructor
@@ -47735,22 +48028,29 @@ Phaser.RandomDataGenerator.prototype = {
47735
48028
  /**
47736
48029
  * Reset the seed of the random data generator.
47737
48030
  *
48031
+ * _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present.
48032
+ *
47738
48033
  * @method Phaser.RandomDataGenerator#sow
47739
- * @param {any[]} seeds
48034
+ * @param {any[]} seeds - The array of seeds: the `toString()` of each value is used.
47740
48035
  */
47741
48036
  sow: function (seeds) {
47742
48037
 
47743
- if (typeof seeds === "undefined") { seeds = []; }
47744
-
48038
+ // Always reset to default seed
47745
48039
  this.s0 = this.hash(' ');
47746
48040
  this.s1 = this.hash(this.s0);
47747
48041
  this.s2 = this.hash(this.s1);
47748
48042
  this.c = 1;
47749
48043
 
47750
- var seed;
48044
+ if (!seeds)
48045
+ {
48046
+ return;
48047
+ }
47751
48048
 
47752
- for (var i = 0; seed = seeds[i++]; )
48049
+ // Apply any seeds
48050
+ for (var i = 0; i < seeds.length && (seeds[i] != null); i++)
47753
48051
  {
48052
+ var seed = seeds[i];
48053
+
47754
48054
  this.s0 -= this.hash(seed);
47755
48055
  this.s0 += ~~(this.s0 < 0);
47756
48056
  this.s1 -= this.hash(seed);
@@ -49168,7 +49468,7 @@ Phaser.Tween.prototype = {
49168
49468
 
49169
49469
  if (complete)
49170
49470
  {
49171
- this.onComplete.dispatch(this);
49471
+ this.onComplete.dispatch(this.target, this);
49172
49472
 
49173
49473
  if (this.chainedTween)
49174
49474
  {
@@ -49185,6 +49485,7 @@ Phaser.Tween.prototype = {
49185
49485
  /**
49186
49486
  * Sets the delay in milliseconds before this tween will start. If there are child tweens it sets the delay before the first child starts.
49187
49487
  * The delay is invoked as soon as you call `Tween.start`. If the tween is already running this method doesn't do anything for the current active tween.
49488
+ * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to delay.
49188
49489
  * If you have child tweens and pass -1 as the index value it sets the delay across all of them.
49189
49490
  *
49190
49491
  * @method Phaser.Tween#delay
@@ -49194,6 +49495,8 @@ Phaser.Tween.prototype = {
49194
49495
  */
49195
49496
  delay: function (duration, index) {
49196
49497
 
49498
+ if (this.timeline.length === 0) { return this; }
49499
+
49197
49500
  if (typeof index === 'undefined') { index = 0; }
49198
49501
 
49199
49502
  if (index === -1)
@@ -49214,6 +49517,7 @@ Phaser.Tween.prototype = {
49214
49517
 
49215
49518
  /**
49216
49519
  * Sets the number of times this tween will repeat.
49520
+ * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to repeat.
49217
49521
  * If you have child tweens and pass -1 as the index value it sets the number of times they'll repeat across all of them.
49218
49522
  * If you wish to define how many times this Tween and all children will repeat see Tween.repeatAll.
49219
49523
  *
@@ -49224,6 +49528,8 @@ Phaser.Tween.prototype = {
49224
49528
  */
49225
49529
  repeat: function (total, index) {
49226
49530
 
49531
+ if (this.timeline.length === 0) { return this; }
49532
+
49227
49533
  if (typeof index === 'undefined') { index = 0; }
49228
49534
 
49229
49535
  if (index === -1)
@@ -49245,6 +49551,7 @@ Phaser.Tween.prototype = {
49245
49551
  /**
49246
49552
  * A Tween that has yoyo set to true will run through from its starting values to its end values and then play back in reverse from end to start.
49247
49553
  * Used in combination with repeat you can create endless loops.
49554
+ * If you have not yet called `Tween.to` or `Tween.from` at least once then this method will do nothing, as there are no tweens to yoyo.
49248
49555
  * If you have child tweens and pass -1 as the index value it sets the yoyo property across all of them.
49249
49556
  * If you wish to yoyo this Tween and all of its children then see Tween.yoyoAll.
49250
49557
  *
@@ -49255,6 +49562,8 @@ Phaser.Tween.prototype = {
49255
49562
  */
49256
49563
  yoyo: function(enable, index) {
49257
49564
 
49565
+ if (this.timeline.length === 0) { return this; }
49566
+
49258
49567
  if (typeof index === 'undefined') { index = 0; }
49259
49568
 
49260
49569
  if (index === -1)
@@ -50470,6 +50779,8 @@ Phaser.Easing = {
50470
50779
  */
50471
50780
  In: function ( k ) {
50472
50781
 
50782
+ if (k === 0) return 0;
50783
+ if (k === 1) return 1;
50473
50784
  return 1 - Math.cos( k * Math.PI / 2 );
50474
50785
 
50475
50786
  },
@@ -50483,6 +50794,8 @@ Phaser.Easing = {
50483
50794
  */
50484
50795
  Out: function ( k ) {
50485
50796
 
50797
+ if (k === 0) return 0;
50798
+ if (k === 1) return 1;
50486
50799
  return Math.sin( k * Math.PI / 2 );
50487
50800
 
50488
50801
  },
@@ -50496,6 +50809,8 @@ Phaser.Easing = {
50496
50809
  */
50497
50810
  InOut: function ( k ) {
50498
50811
 
50812
+ if (k === 0) return 0;
50813
+ if (k === 1) return 1;
50499
50814
  return 0.5 * ( 1 - Math.cos( Math.PI * k ) );
50500
50815
 
50501
50816
  }
@@ -51300,7 +51615,7 @@ Phaser.Time.prototype = {
51300
51615
  */
51301
51616
  reset: function () {
51302
51617
 
51303
- this._started = this.now;
51618
+ this._started = this.time;
51304
51619
  this.removeAll();
51305
51620
 
51306
51621
  }
@@ -52583,10 +52898,13 @@ Phaser.AnimationManager.prototype = {
52583
52898
  }
52584
52899
 
52585
52900
  this._anims = {};
52901
+ this._outputFrames = [];
52586
52902
  this._frameData = null;
52587
52903
  this._frameIndex = 0;
52588
52904
  this.currentAnim = null;
52589
52905
  this.currentFrame = null;
52906
+ this.sprite = null;
52907
+ this.game = null;
52590
52908
 
52591
52909
  }
52592
52910
 
@@ -56602,7 +56920,7 @@ Phaser.Loader.prototype = {
56602
56920
  *
56603
56921
  * @method Phaser.Loader#audio
56604
56922
  * @param {string} key - Unique asset key of the audio file.
56605
- * @param {Array|string} urls - An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ] or a single string containing just one URL.
56923
+ * @param {Array|string} urls - An array containing the URLs of the audio files, i.e.: [ 'jump.mp3', 'jump.ogg', 'jump.m4a' ] or a single string containing just one URL. BLOB urls are supported, but note that Phaser will not validate the audio file's type if a BLOB is provided; the user should ensure that a BLOB url is playable.
56606
56924
  * @param {boolean} autoDecode - When using Web Audio the audio files can either be decoded at load time or run-time. They can't be played until they are decoded, but this let's you control when that happens. Decoding is a non-blocking async process.
56607
56925
  * @return {Phaser.Loader} This Loader instance.
56608
56926
  */
@@ -57391,6 +57709,12 @@ Phaser.Loader.prototype = {
57391
57709
  for (var i = 0; i < urls.length; i++)
57392
57710
  {
57393
57711
  extension = urls[i].toLowerCase();
57712
+
57713
+ if (extension.substr(0,5) === "blob:")
57714
+ {
57715
+ return urls[i];
57716
+ }
57717
+
57394
57718
  extension = extension.substr((Math.max(0, extension.lastIndexOf(".")) || Infinity) + 1);
57395
57719
 
57396
57720
  if (extension.indexOf("?") >= 0)
@@ -57998,16 +58322,9 @@ Phaser.AudioSprite = function (game, key) {
57998
58322
  {
57999
58323
  var marker = this.config.spritemap[k];
58000
58324
  var sound = this.game.add.sound(this.key);
58001
-
58002
- if (marker.loop)
58003
- {
58004
- sound.addMarker(k, marker.start, (marker.end - marker.start), null, true);
58005
- }
58006
- else
58007
- {
58008
- sound.addMarker(k, marker.start, (marker.end - marker.start), null, false);
58009
- }
58010
-
58325
+
58326
+ sound.addMarker(k, marker.start, (marker.end - marker.start), null, marker.loop);
58327
+
58011
58328
  this.sounds[k] = sound;
58012
58329
  }
58013
58330
 
@@ -58526,7 +58843,7 @@ Phaser.Sound.prototype = {
58526
58843
  */
58527
58844
  play: function (marker, position, volume, loop, forceRestart) {
58528
58845
 
58529
- if (typeof marker === 'undefined') { marker = ''; }
58846
+ if (typeof marker === 'undefined' || marker === false || marker === null) { marker = ''; }
58530
58847
  if (typeof forceRestart === 'undefined') { forceRestart = true; }
58531
58848
 
58532
58849
  if (this.isPlaying && !this.allowMultiple && !forceRestart && !this.override)
@@ -58535,7 +58852,7 @@ Phaser.Sound.prototype = {
58535
58852
  return this;
58536
58853
  }
58537
58854
 
58538
- if (this.isPlaying && !this.allowMultiple && (this.override || forceRestart))
58855
+ if (this._sound && this.isPlaying && !this.allowMultiple && (this.override || forceRestart))
58539
58856
  {
58540
58857
  if (this.usingWebAudio)
58541
58858
  {
@@ -58545,7 +58862,11 @@ Phaser.Sound.prototype = {
58545
58862
  }
58546
58863
  else
58547
58864
  {
58548
- this._sound.stop(0);
58865
+ try {
58866
+ this._sound.stop(0);
58867
+ }
58868
+ catch (e) {
58869
+ }
58549
58870
  }
58550
58871
  }
58551
58872
  else if (this.usingAudioTag)
@@ -58555,10 +58876,17 @@ Phaser.Sound.prototype = {
58555
58876
  }
58556
58877
  }
58557
58878
 
58558
- this.currentMarker = marker;
58879
+ if (marker === '' && Object.keys(this.markers).length > 0)
58880
+ {
58881
+ // If they didn't specify a marker but this is an audio sprite,
58882
+ // we should never play the entire thing
58883
+ return this;
58884
+ }
58559
58885
 
58560
58886
  if (marker !== '')
58561
58887
  {
58888
+ this.currentMarker = marker;
58889
+
58562
58890
  if (this.markers[marker])
58563
58891
  {
58564
58892
  // Playing a marker? Then we default to the marker values
@@ -63024,7 +63352,7 @@ Phaser.Physics.Arcade.prototype = {
63024
63352
  * @param {function} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are colliding Group vs. Sprite, in which case Sprite will always be the first parameter.
63025
63353
  * @param {function} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then collision will only happen if processCallback returns true. The two objects will be passed to this function in the same order in which you specified them.
63026
63354
  * @param {object} [callbackContext] - The context in which to run the callbacks.
63027
- * @return {boolean} True if a collision occured otherwise false.
63355
+ * @return {boolean} True if a collision occurred otherwise false.
63028
63356
  */
63029
63357
  collide: function (object1, object2, collideCallback, processCallback, callbackContext) {
63030
63358
 
@@ -63620,7 +63948,7 @@ Phaser.Physics.Arcade.prototype = {
63620
63948
  */
63621
63949
  separateY: function (body1, body2, overlapOnly) {
63622
63950
 
63623
- // Can't separate two immovable or non-existing bodys
63951
+ // Can't separate two immovable or non-existing bodies
63624
63952
  if (body1.immovable && body2.immovable)
63625
63953
  {
63626
63954
  return false;
@@ -63751,7 +64079,7 @@ Phaser.Physics.Arcade.prototype = {
63751
64079
  // We re-check for collision in case body was separated in a previous step
63752
64080
  if (!body.enable || !tile.intersects(body.position.x, body.position.y, body.right, body.bottom))
63753
64081
  {
63754
- // no collision so bail out (separted in a previous step)
64082
+ // no collision so bail out (separated in a previous step)
63755
64083
  return false;
63756
64084
  }
63757
64085
 
@@ -63847,7 +64175,7 @@ Phaser.Physics.Arcade.prototype = {
63847
64175
  * @method Phaser.Physics.Arcade#tileCheckX
63848
64176
  * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate.
63849
64177
  * @param {Phaser.Tile} tile - The tile to check.
63850
- * @return {number} The amount of separation that occured.
64178
+ * @return {number} The amount of separation that occurred.
63851
64179
  */
63852
64180
  tileCheckX: function (body, tile) {
63853
64181
 
@@ -63896,7 +64224,7 @@ Phaser.Physics.Arcade.prototype = {
63896
64224
  * @method Phaser.Physics.Arcade#tileCheckY
63897
64225
  * @param {Phaser.Physics.Arcade.Body} body - The Body object to separate.
63898
64226
  * @param {Phaser.Tile} tile - The tile to check.
63899
- * @return {number} The amount of separation that occured.
64227
+ * @return {number} The amount of separation that occurred.
63900
64228
  */
63901
64229
  tileCheckY: function (body, tile) {
63902
64230
 
@@ -65487,7 +65815,7 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
65487
65815
  this.angularDrag = 0;
65488
65816
 
65489
65817
  /**
65490
- * @property {boolean} frequency - How often a particle is emitted in ms (if emitter is started with Explode === false).
65818
+ * @property {number} frequency - How often a particle is emitted in ms (if emitter is started with Explode === false).
65491
65819
  * @default
65492
65820
  */
65493
65821
  this.frequency = 100;
@@ -65608,25 +65936,24 @@ Phaser.Particles.Arcade.Emitter.prototype.constructor = Phaser.Particles.Arcade.
65608
65936
 
65609
65937
  /**
65610
65938
  * Called automatically by the game loop, decides when to launch particles and when to "die".
65939
+ *
65611
65940
  * @method Phaser.Particles.Arcade.Emitter#update
65612
65941
  */
65613
65942
  Phaser.Particles.Arcade.Emitter.prototype.update = function () {
65614
65943
 
65615
65944
  if (this.on && this.game.time.time >= this._timer)
65616
65945
  {
65617
- this.emitParticle();
65618
-
65619
- this._counter++;
65946
+ this._timer = this.game.time.time + this.frequency * this.game.time.slowMotion;
65620
65947
 
65621
- if (this._quantity > 0)
65948
+ if (this.emitParticle())
65622
65949
  {
65623
- if (this._counter >= this._quantity)
65950
+ this._counter++;
65951
+
65952
+ if (this._quantity > 0 && this._counter >= this._quantity)
65624
65953
  {
65625
65954
  this.on = false;
65626
65955
  }
65627
65956
  }
65628
-
65629
- this._timer = this.game.time.time + this.frequency * this.game.time.slowMotion;
65630
65957
  }
65631
65958
 
65632
65959
  var i = this.children.length;
@@ -65648,7 +65975,7 @@ Phaser.Particles.Arcade.Emitter.prototype.update = function () {
65648
65975
  * @method Phaser.Particles.Arcade.Emitter#makeParticles
65649
65976
  * @param {array|string} keys - A string or an array of strings that the particle sprites will use as their texture. If an array one is picked at random.
65650
65977
  * @param {array|number} [frames=0] - A frame number, or array of frames that the sprite will use. If an array one is picked at random.
65651
- * @param {number} [quantity] - The number of particles to generate. If not given it will use the value of Emitter.maxParticles.
65978
+ * @param {number} [quantity] - The number of particles to generate. If not given it will use the value of Emitter.maxParticles. If the value is greater than Emitter.maxParticles it will use Emitter.maxParticles as the quantity.
65652
65979
  * @param {boolean} [collide=false] - If you want the particles to be able to collide with other Arcade Physics bodies then set this to true.
65653
65980
  * @param {boolean} [collideWorldBounds=false] - A particle can be set to collide against the World bounds automatically and rebound back into the World if this is set to true. Otherwise it will leave the World.
65654
65981
  * @return {Phaser.Particles.Arcade.Emitter} This Emitter instance.
@@ -65666,6 +65993,11 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
65666
65993
  var rndFrame = frames;
65667
65994
  this._frames = frames;
65668
65995
 
65996
+ if (quantity > this.maxParticles)
65997
+ {
65998
+ this.maxParticles = quantity;
65999
+ }
66000
+
65669
66001
  while (i < quantity)
65670
66002
  {
65671
66003
  if (Array.isArray(keys))
@@ -65767,8 +66099,8 @@ Phaser.Particles.Arcade.Emitter.prototype.flow = function (lifespan, frequency,
65767
66099
  * @param {boolean} [explode=true] - Whether the particles should all burst out at once (true) or at the frequency given (false).
65768
66100
  * @param {number} [lifespan=0] - How long each particle lives once emitted in ms. 0 = forever.
65769
66101
  * @param {number} [frequency=250] - Ignored if Explode is set to true. Frequency is how often to emit 1 particle. Value given in ms.
65770
- * @param {number} [quantity=0] - How many particles to launch. 0 = "all of the particles".
65771
- * @param {number} [forceQuantity=false] - If true and creating a particle flow, the quantity emitted will be forced to the be quantity given in this call.
66102
+ * @param {number} [quantity=0] - How many particles to launch. 0 = "all of the particles" which will keep emitting until Emitter.maxParticles is reached.
66103
+ * @param {number} [forceQuantity=false] - If `true` and creating a particle flow, the quantity emitted will be forced to the be quantity given in this call. This can never exceed Emitter.maxParticles.
65772
66104
  */
65773
66105
  Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, frequency, quantity, forceQuantity) {
65774
66106
 
@@ -65778,6 +66110,11 @@ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, f
65778
66110
  if (typeof quantity === 'undefined') { quantity = 0; }
65779
66111
  if (typeof forceQuantity === 'undefined') { forceQuantity = false; }
65780
66112
 
66113
+ if (quantity > this.maxParticles)
66114
+ {
66115
+ quantity = this.maxParticles;
66116
+ }
66117
+
65781
66118
  this.revive();
65782
66119
 
65783
66120
  this.visible = true;
@@ -65806,6 +66143,7 @@ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, f
65806
66143
  * This function can be used both internally and externally to emit the next particle in the queue.
65807
66144
  *
65808
66145
  * @method Phaser.Particles.Arcade.Emitter#emitParticle
66146
+ * @return {boolean} True if a particle was emitted, otherwise false.
65809
66147
  */
65810
66148
  Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
65811
66149
 
@@ -65813,7 +66151,7 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
65813
66151
 
65814
66152
  if (particle === null)
65815
66153
  {
65816
- return;
66154
+ return false;
65817
66155
  }
65818
66156
 
65819
66157
  if (this.width > 1 || this.height > 1)
@@ -65887,6 +66225,8 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () {
65887
66225
 
65888
66226
  particle.onEmit();
65889
66227
 
66228
+ return true;
66229
+
65890
66230
  };
65891
66231
 
65892
66232
  /**
@@ -68480,6 +68820,7 @@ Object.defineProperty(Phaser.Tilemap.prototype, "layer", {
68480
68820
  * A TilemapLayer is a Phaser.Image/Sprite that renders a specific TileLayer of a Tilemap.
68481
68821
  *
68482
68822
  * Since a TilemapLayer is a Sprite it can be moved around the display, added to other groups or display objects, etc.
68823
+ *
68483
68824
  * By default TilemapLayers have fixedToCamera set to `true`. Changing this will break Camera follow and scrolling behaviour.
68484
68825
  *
68485
68826
  * @class Phaser.TilemapLayer
@@ -68533,7 +68874,7 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
68533
68874
  * @property {HTMLCanvasElement} canvas
68534
68875
  * @protected
68535
68876
  */
68536
- this.canvas = Phaser.Canvas.create(width, height, '', true);
68877
+ this.canvas = Phaser.Canvas.create(width, height);
68537
68878
 
68538
68879
  /**
68539
68880
  * The 2d context of the canvas.
@@ -68596,15 +68937,24 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
68596
68937
  /**
68597
68938
  * Settings that control standard (non-diagnostic) rendering.
68598
68939
  *
68599
- * @public
68600
- * @property {boolean} enableScrollDelta - When enabled, only new newly exposed areas of the layer are redraw after scrolling. This can greatly improve scrolling rendering performance, especially when there are many small tiles.
68940
+ * @property {boolean} [enableScrollDelta=true] - Delta scroll rendering only draws tiles/edges as them come into view.
68941
+ * This can greatly improve scrolling rendering performance, especially when there are many small tiles.
68942
+ * It should only be disabled in rare cases.
68943
+ *
68944
+ * @property {?DOMCanvasElement} [copyCanvas=(auto)] - [Internal] If set, force using a separate (shared) copy canvas.
68945
+ * Using a canvas bitblt/copy when the source and destinations region overlap produces unexpected behavior
68946
+ * in some browsers, notably Safari.
68947
+ *
68948
+ * @property {integer} copySliceCount - [Internal] The number of vertical slices to copy when using a `copyCanvas`.
68949
+ * This is ratio of the pixel count of the primary canvas to the copy canvas.
68950
+ *
68601
68951
  * @default
68602
68952
  */
68603
68953
  this.renderSettings = {
68604
-
68605
68954
  enableScrollDelta: true,
68606
- overdrawRatio: 0.20
68607
-
68955
+ overdrawRatio: 0.20,
68956
+ copyCanvas: null,
68957
+ copySliceCount: 4
68608
68958
  };
68609
68959
 
68610
68960
  /**
@@ -68729,6 +69079,35 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
68729
69079
  */
68730
69080
  this._results = [];
68731
69081
 
69082
+ if (!game.device.canvasBitBltShift)
69083
+ {
69084
+ this.renderSettings.copyCanvas = Phaser.TilemapLayer.ensureSharedCopyCanvas();
69085
+ }
69086
+
69087
+ };
69088
+
69089
+ /**
69090
+ * The shared double-copy canvas, created as needed.
69091
+ *
69092
+ * @private
69093
+ * @static
69094
+ */
69095
+ Phaser.TilemapLayer.sharedCopyCanvas = null;
69096
+
69097
+ /**
69098
+ * Create if needed (and return) a shared copy canvas that is shared across all TilemapLayers.
69099
+ *
69100
+ * Code that uses the canvas is responsible to ensure the dimensions and save/restore state as appropriate.
69101
+ *
69102
+ * @protected
69103
+ * @static
69104
+ */
69105
+ Phaser.TilemapLayer.ensureSharedCopyCanvas = function () {
69106
+ if (!this.sharedCopyCanvas)
69107
+ {
69108
+ this.sharedCopyCanvas = Phaser.Canvas.create(2, 2);
69109
+ }
69110
+ return this.sharedCopyCanvas;
68732
69111
  };
68733
69112
 
68734
69113
  Phaser.TilemapLayer.prototype = Object.create(Phaser.Image.prototype);
@@ -69006,9 +69385,6 @@ Phaser.TilemapLayer.prototype.getTiles = function (x, y, width, height, collides
69006
69385
  x = this._fixX(x);
69007
69386
  y = this._fixY(y);
69008
69387
 
69009
- var tw = this._mc.tileWidth;
69010
- var th = this._mc.tileHeight;
69011
-
69012
69388
  // Convert the pixel values into tile coordinates
69013
69389
  var tx = Math.floor(x / this._mc.cw);
69014
69390
  var ty = Math.floor(y / this._mc.ch);
@@ -69062,7 +69438,8 @@ Object.defineProperty(Phaser.TilemapLayer.prototype, "wrap", {
69062
69438
  });
69063
69439
 
69064
69440
  /**
69065
- * Returns the appropriate tileset for the index, updating the internal cache as required. This should only be called if `tilesets[index]` evaluates to undefined.
69441
+ * Returns the appropriate tileset for the index, updating the internal cache as required.
69442
+ * This should only be called if `tilesets[index]` evaluates to undefined.
69066
69443
  *
69067
69444
  * @method Phaser.TilemapLayer#resolveTileset
69068
69445
  * @private
@@ -69096,7 +69473,9 @@ Phaser.TilemapLayer.prototype.resolveTileset = function (tileIndex)
69096
69473
  };
69097
69474
 
69098
69475
  /**
69099
- * The TilemapLayer caches tileset look-ups. Call this method of clear the cache if tilesets have been added or updated after the layer has been rendered.
69476
+ * The TilemapLayer caches tileset look-ups.
69477
+ *
69478
+ * Call this method of clear the cache if tilesets have been added or updated after the layer has been rendered.
69100
69479
  *
69101
69480
  * @method Phaser.TilemapLayer#resetTilesetCache
69102
69481
  * @public
@@ -69112,7 +69491,9 @@ Phaser.TilemapLayer.prototype.resetTilesetCache = function ()
69112
69491
  };
69113
69492
 
69114
69493
  /**
69115
- * Shifts the contents of the canvas - does extra math so that different browsers agree on the result. The specified (x/y) will be shifted to (0,0) after the copy. The newly exposed canvas area will need to be filled in. This method is problematic for transparent tiles.
69494
+ * Shifts the contents of the canvas - does extra math so that different browsers agree on the result.
69495
+ *
69496
+ * The specified (x/y) will be shifted to (0,0) after the copy and the newly exposed canvas area will need to be filled in.
69116
69497
  *
69117
69498
  * @method Phaser.TilemapLayer#shiftCanvas
69118
69499
  * @private
@@ -69145,10 +69526,53 @@ Phaser.TilemapLayer.prototype.shiftCanvas = function (context, x, y)
69145
69526
  sy = 0;
69146
69527
  }
69147
69528
 
69148
- context.save();
69149
- context.globalCompositeOperation = 'copy';
69150
- context.drawImage(canvas, dx, dy, copyW, copyH, sx, sy, copyW, copyH);
69151
- context.restore();
69529
+ var copyCanvas = this.renderSettings.copyCanvas;
69530
+ if (copyCanvas)
69531
+ {
69532
+ // Copying happens in slices to minimize copy canvas size overhead
69533
+ var sliceCount = this.renderSettings.copySliceCount;
69534
+ var sH = Math.ceil(copyH / sliceCount);
69535
+ // Ensure copy canvas is large enough
69536
+ if (copyCanvas.width < copyW) { copyCanvas.width = copyW; }
69537
+ if (copyCanvas.height < sH) { copyCanvas.height = sH; }
69538
+
69539
+ var vShift;
69540
+ if (dy >= sy)
69541
+ {
69542
+ // move old region up, or don't change vertically - copy top to bottom
69543
+ vShift = sH;
69544
+ }
69545
+ else
69546
+ {
69547
+ // move old region down - copy segments from bottom to top
69548
+ vShift = -sH;
69549
+ dy += (sH * (sliceCount - 1));
69550
+ sy += (sH * (sliceCount - 1));
69551
+ }
69552
+
69553
+ var copyContext = copyCanvas.getContext('2d');
69554
+ while (sliceCount--)
69555
+ {
69556
+ copyContext.clearRect(0, 0, copyW, sH);
69557
+ copyContext.drawImage(canvas, dx, dy, copyW, sH, 0, 0, copyW, sH);
69558
+ // clear allows default 'source-over' semantics
69559
+ context.clearRect(sx, sy, copyW, sH);
69560
+ context.drawImage(copyCanvas, 0, 0, copyW, sH, sx, sy, copyW, sH);
69561
+
69562
+ dy += vShift;
69563
+ sy += vShift;
69564
+ }
69565
+
69566
+ }
69567
+ else
69568
+ {
69569
+ // Avoids a second copy but flickers in Safari / Safari Mobile
69570
+ // Ref. https://github.com/photonstorm/phaser/issues/1439
69571
+ context.save();
69572
+ context.globalCompositeOperation = 'copy';
69573
+ context.drawImage(canvas, dx, dy, copyW, copyH, sx, sy, copyW, copyH);
69574
+ context.restore();
69575
+ }
69152
69576
  };
69153
69577
 
69154
69578
  /**
@@ -69957,7 +70381,7 @@ Phaser.TilemapParser = {
69957
70381
  // name, firstgid, width, height, margin, spacing, properties
69958
70382
  var set = json.tilesets[i];
69959
70383
 
69960
- if (!set.tiles)
70384
+ if (set.image)
69961
70385
  {
69962
70386
  var newSet = new Phaser.Tileset(set.name, set.firstgid, set.tilewidth, set.tileheight, set.margin, set.spacing, set.properties);
69963
70387
 
@@ -84101,10 +84525,22 @@ Phaser.Physics.P2 = function (game, config) {
84101
84525
  */
84102
84526
  this.game = game;
84103
84527
 
84104
- if (typeof config === 'undefined' || !config.hasOwnProperty('gravity') || !config.hasOwnProperty('broadphase'))
84528
+ if (typeof config === 'undefined')
84105
84529
  {
84106
84530
  config = { gravity: [0, 0], broadphase: new p2.SAPBroadphase() };
84107
84531
  }
84532
+ else
84533
+ {
84534
+ if (!config.hasOwnProperty('gravity'))
84535
+ {
84536
+ config.gravity = [0, 0];
84537
+ }
84538
+
84539
+ if (!config.hasOwnProperty('broadphase'))
84540
+ {
84541
+ config.broadphase = new p2.SAPBroadphase();
84542
+ }
84543
+ }
84108
84544
 
84109
84545
  /**
84110
84546
  * @property {object} config - The p2 World configuration object.
@@ -84432,16 +84868,16 @@ Phaser.Physics.P2.prototype = {
84432
84868
  */
84433
84869
  postBroadphaseHandler: function (event) {
84434
84870
 
84435
- var i = event.pairs.length;
84871
+ if (!this.postBroadphaseCallback || event.pairs.length === 0)
84872
+ {
84873
+ return;
84874
+ }
84436
84875
 
84437
- if (this.postBroadphaseCallback && i > 0)
84876
+ for (var i = event.pairs.length - 2; i >= 0; i -= 2)
84438
84877
  {
84439
- while (i -= 2)
84878
+ if (event.pairs[i].parent && event.pairs[i+1].parent && !this.postBroadphaseCallback.call(this.callbackContext, event.pairs[i].parent, event.pairs[i+1].parent))
84440
84879
  {
84441
- if (event.pairs[i].parent && event.pairs[i+1].parent && !this.postBroadphaseCallback.call(this.callbackContext, event.pairs[i].parent, event.pairs[i+1].parent))
84442
- {
84443
- event.pairs.splice(i, 2);
84444
- }
84880
+ event.pairs.splice(i, 2);
84445
84881
  }
84446
84882
  }
84447
84883