Skip to content

Commit 9654068

Browse files
committed
Merge branch 'master' of https://github.com/photonstorm/phaser
2 parents eb6b6e1 + 0c895db commit 9654068

22 files changed

Lines changed: 252 additions & 1081 deletions

.github/CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Before contributing, please read the [code of conduct](https://github.com/photon
1414

1515
**3. Create an isolated and reproducible test case.** If you are reporting a bug, make sure you also have a minimal, runnable, code example that reproduces the problem you have.
1616

17-
**4. Include a live example.** After narrowing your code down to only the problem areas, make use of [jsFiddle][1], [jsBin][2], or a link to your live site so that we can view a live example of the problem.
17+
**4. Include a live example.** After narrowing your code down to only the problem areas, make use of [jsFiddle][1], [jsBin][2], [CodePen][5], or a link to your live site so that we can view a live example of the problem.
1818

1919
**5. Share as much information as possible.** Include browser version affected, your OS, version of the library, steps to reproduce, etc. "X isn't working!!!1!" will probably just be closed.
2020

@@ -74,3 +74,4 @@ Thanks to Chad for creating the original Pixi.js Contributing file which we adap
7474
[2]: http://jsbin.com/
7575
[3]: http://nodejs.org
7676
[4]: http://www.html5gamedevs.com/forum/14-phaser/
77+
[5]: https://codepen.io/pen?template=YeEWom "Phaser 3 game template"

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This Issue is about (delete as applicable)
1010
* An error on the web site
1111
* A problem with my own code
1212

13-
API errors must include example code showing what happens, and why you don't believe this is the expected behavior. Issues posted without code take _far_ longer to get resolved, _if ever_. Feel free to use a site such as jsbin to demo the problem. If we can run it, and see the error, we can usually fix it.
13+
API errors must include example code showing what happens, and why you don't believe this is the expected behavior. Issues posted without code take _far_ longer to get resolved, _if ever_. Feel free to use a site such as jsBin or [CodePen](https://codepen.io/pen?template=YeEWom) to demo the problem. If we can run it, and see the error, we can usually fix it.
1414

1515
If your Issue contains _any_ form of hostility it will be instantly closed.
1616

src/cameras/2d/Camera.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,12 @@ var Camera = new Class({
13231323
{
13241324
this._shakeOffsetX = (Math.random() * intensity * this.width * 2 - intensity * this.width) * this.zoom;
13251325
this._shakeOffsetY = (Math.random() * intensity * this.height * 2 - intensity * this.height) * this.zoom;
1326+
1327+
if (this.roundPixels)
1328+
{
1329+
this._shakeOffsetX |= 0;
1330+
this._shakeOffsetY |= 0;
1331+
}
13261332
}
13271333
}
13281334
},

src/physics/arcade/World.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ var World = new Class({
695695
var body;
696696

697697
var dynamic = this.bodies;
698-
var static = this.staticBodies;
698+
var staticBodies = this.staticBodies;
699699
var pending = this.pendingDestroy;
700700

701701
var bodies = dynamic.entries;
@@ -727,7 +727,7 @@ var World = new Class({
727727
}
728728
}
729729

730-
bodies = static.entries;
730+
bodies = staticBodies.entries;
731731
len = bodies.length;
732732

733733
for (i = 0; i < len; i++)
@@ -761,7 +761,7 @@ var World = new Class({
761761
else if (body.physicsType === CONST.STATIC_BODY)
762762
{
763763
staticTree.remove(body);
764-
static.delete(body);
764+
staticBodies.delete(body);
765765
}
766766

767767
body.world = undefined;

src/renderer/webgl/Utils.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,19 @@ module.exports = {
9797
* @since 3.0.0
9898
*
9999
* @param {number} attributes - [description]
100+
* @param {WebGLRenderingContext} glContext - [description]
100101
*
101102
* @return {number} [description]
102103
*/
103-
getComponentCount: function (attributes)
104+
getComponentCount: function (attributes, glContext)
104105
{
105106
var count = 0;
106107

107108
for (var index = 0; index < attributes.length; ++index)
108109
{
109110
var element = attributes[index];
110111

111-
if (element.type === WebGLRenderingContext.FLOAT)
112+
if (element.type === glContext.FLOAT)
112113
{
113114
count += element.size;
114115
}

src/renderer/webgl/WebGLPipeline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ var WebGLPipeline = new Class({
185185
* @type {integer}
186186
* @since 3.0.0
187187
*/
188-
this.vertexComponentCount = Utils.getComponentCount(config.attributes);
188+
this.vertexComponentCount = Utils.getComponentCount(config.attributes, this.gl);
189189

190190
/**
191191
* Indicates if the current pipeline is flushing the contents to the GPU.

src/renderer/webgl/WebGLRenderer.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,6 @@ var WebGLRenderer = new Class({
179179
encoder: null
180180
};
181181

182-
for (var i = 0; i <= 16; i++)
183-
{
184-
this.blendModes.push({ func: [ WebGLRenderingContext.ONE, WebGLRenderingContext.ONE_MINUS_SRC_ALPHA ], equation: WebGLRenderingContext.FUNC_ADD });
185-
}
186-
187-
this.blendModes[1].func = [ WebGLRenderingContext.ONE, WebGLRenderingContext.DST_ALPHA ];
188-
this.blendModes[2].func = [ WebGLRenderingContext.DST_COLOR, WebGLRenderingContext.ONE_MINUS_SRC_ALPHA ];
189-
this.blendModes[3].func = [ WebGLRenderingContext.ONE, WebGLRenderingContext.ONE_MINUS_SRC_COLOR ];
190-
191182
// Internal Renderer State (Textures, Framebuffers, Pipelines, Buffers, etc)
192183

193184
/**
@@ -389,6 +380,15 @@ var WebGLRenderer = new Class({
389380

390381
this.gl = gl;
391382

383+
for (var i = 0; i <= 16; i++)
384+
{
385+
this.blendModes.push({ func: [ gl.ONE, gl.ONE_MINUS_SRC_ALPHA ], equation: gl.FUNC_ADD });
386+
}
387+
388+
this.blendModes[1].func = [ gl.ONE, gl.DST_ALPHA ];
389+
this.blendModes[2].func = [ gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA ];
390+
this.blendModes[3].func = [ gl.ONE, gl.ONE_MINUS_SRC_COLOR ];
391+
392392
// Load supported extensions
393393
this.supportedExtensions = gl.getSupportedExtensions();
394394

src/renderer/webgl/pipelines/FlatTintPipeline.js

Lines changed: 13 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,8 @@ var FlatTintPipeline = new Class({
196196
* @param {float} e1 - [description]
197197
* @param {float} f1 - [description]
198198
* @param {Float32Array} currentMatrix - [description]
199-
* @param {boolean} roundPixels - [description]
200199
*/
201-
batchFillRect: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x, y, width, height, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix, roundPixels)
200+
batchFillRect: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x, y, width, height, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix)
202201
{
203202
this.renderer.setPipeline(this);
204203

@@ -236,18 +235,6 @@ var FlatTintPipeline = new Class({
236235
var ty3 = xw * b + y * d + f;
237236
var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha);
238237

239-
if (roundPixels)
240-
{
241-
tx0 = ((tx0 * resolution)|0) / resolution;
242-
ty0 = ((ty0 * resolution)|0) / resolution;
243-
tx1 = ((tx1 * resolution)|0) / resolution;
244-
ty1 = ((ty1 * resolution)|0) / resolution;
245-
tx2 = ((tx2 * resolution)|0) / resolution;
246-
ty2 = ((ty2 * resolution)|0) / resolution;
247-
tx3 = ((tx3 * resolution)|0) / resolution;
248-
ty3 = ((ty3 * resolution)|0) / resolution;
249-
}
250-
251238
vertexViewF32[vertexOffset + 0] = tx0;
252239
vertexViewF32[vertexOffset + 1] = ty0;
253240
vertexViewU32[vertexOffset + 2] = tint;
@@ -296,9 +283,8 @@ var FlatTintPipeline = new Class({
296283
* @param {float} e1 - [description]
297284
* @param {float} f1 - [description]
298285
* @param {Float32Array} currentMatrix - [description]
299-
* @param {boolean} roundPixels - [description]
300286
*/
301-
batchFillTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix, roundPixels)
287+
batchFillTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix)
302288
{
303289
this.renderer.setPipeline(this);
304290

@@ -332,16 +318,6 @@ var FlatTintPipeline = new Class({
332318
var ty2 = x2 * b + y2 * d + f;
333319
var tint = Utils.getTintAppendFloatAlphaAndSwap(fillColor, fillAlpha);
334320

335-
if (roundPixels)
336-
{
337-
tx0 = ((tx0 * resolution)|0) / resolution;
338-
ty0 = ((ty0 * resolution)|0) / resolution;
339-
tx1 = ((tx1 * resolution)|0) / resolution;
340-
ty1 = ((ty1 * resolution)|0) / resolution;
341-
tx2 = ((tx2 * resolution)|0) / resolution;
342-
ty2 = ((ty2 * resolution)|0) / resolution;
343-
}
344-
345321
vertexViewF32[vertexOffset + 0] = tx0;
346322
vertexViewF32[vertexOffset + 1] = ty0;
347323
vertexViewU32[vertexOffset + 2] = tint;
@@ -382,9 +358,8 @@ var FlatTintPipeline = new Class({
382358
* @param {float} e - [description]
383359
* @param {float} f - [description]
384360
* @param {Float32Array} currentMatrix - [description]
385-
* @param {boolean} roundPixels - [description]
386361
*/
387-
batchStrokeTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, currentMatrix, roundPixels)
362+
batchStrokeTriangle: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, x0, y0, x1, y1, x2, y2, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, currentMatrix)
388363
{
389364
var tempTriangle = this.tempTriangle;
390365

@@ -414,8 +389,7 @@ var FlatTintPipeline = new Class({
414389
tempTriangle, lineWidth, lineColor, lineAlpha,
415390
a, b, c, d, e, f,
416391
false,
417-
currentMatrix,
418-
roundPixels
392+
currentMatrix
419393
);
420394
},
421395

@@ -440,9 +414,8 @@ var FlatTintPipeline = new Class({
440414
* @param {float} e1 - [description]
441415
* @param {float} f1 - [description]
442416
* @param {Float32Array} currentMatrix - [description]
443-
* @param {boolean} roundPixels - [description]
444417
*/
445-
batchFillPath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix, roundPixels)
418+
batchFillPath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, fillColor, fillAlpha, a1, b1, c1, d1, e1, f1, currentMatrix)
446419
{
447420
this.renderer.setPipeline(this);
448421

@@ -508,16 +481,6 @@ var FlatTintPipeline = new Class({
508481
tx2 = x2 * a + y2 * c + e;
509482
ty2 = x2 * b + y2 * d + f;
510483

511-
if (roundPixels)
512-
{
513-
tx0 = ((tx0 * resolution)|0) / resolution;
514-
ty0 = ((ty0 * resolution)|0) / resolution;
515-
tx1 = ((tx1 * resolution)|0) / resolution;
516-
ty1 = ((ty1 * resolution)|0) / resolution;
517-
tx2 = ((tx2 * resolution)|0) / resolution;
518-
ty2 = ((ty2 * resolution)|0) / resolution;
519-
}
520-
521484
vertexViewF32[vertexOffset + 0] = tx0;
522485
vertexViewF32[vertexOffset + 1] = ty0;
523486
vertexViewU32[vertexOffset + 2] = tint;
@@ -557,9 +520,8 @@ var FlatTintPipeline = new Class({
557520
* @param {float} f - [description]
558521
* @param {boolean} isLastPath - [description]
559522
* @param {Float32Array} currentMatrix - [description]
560-
* @param {boolean} roundPixels - [description]
561523
*/
562-
batchStrokePath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, isLastPath, currentMatrix, roundPixels)
524+
batchStrokePath: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, path, lineWidth, lineColor, lineAlpha, a, b, c, d, e, f, isLastPath, currentMatrix)
563525
{
564526
this.renderer.setPipeline(this);
565527

@@ -585,8 +547,7 @@ var FlatTintPipeline = new Class({
585547
point0.width / 2, point1.width / 2,
586548
point0.rgb, point1.rgb, lineAlpha,
587549
a, b, c, d, e, f,
588-
currentMatrix,
589-
roundPixels
550+
currentMatrix
590551
);
591552

592553
polylines.push(line);
@@ -656,9 +617,8 @@ var FlatTintPipeline = new Class({
656617
* @param {float} e1 - [description]
657618
* @param {float} f1 - [description]
658619
* @param {Float32Array} currentMatrix - [description]
659-
* @param {boolean} roundPixels - [description]
660620
*/
661-
batchLine: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, ax, ay, bx, by, aLineWidth, bLineWidth, aLineColor, bLineColor, lineAlpha, a1, b1, c1, d1, e1, f1, currentMatrix, roundPixels)
621+
batchLine: function (srcX, srcY, srcScaleX, srcScaleY, srcRotation, ax, ay, bx, by, aLineWidth, bLineWidth, aLineColor, bLineColor, lineAlpha, a1, b1, c1, d1, e1, f1, currentMatrix)
662622
{
663623
this.renderer.setPipeline(this);
664624

@@ -711,18 +671,6 @@ var FlatTintPipeline = new Class({
711671
var bTint = getTint(bLineColor, lineAlpha);
712672
var vertexOffset = this.vertexCount * this.vertexComponentCount;
713673

714-
if (roundPixels)
715-
{
716-
x0 = ((x0 * resolution)|0) / resolution;
717-
y0 = ((y0 * resolution)|0) / resolution;
718-
x1 = ((x1 * resolution)|0) / resolution;
719-
y1 = ((y1 * resolution)|0) / resolution;
720-
x2 = ((x2 * resolution)|0) / resolution;
721-
y2 = ((y2 * resolution)|0) / resolution;
722-
x3 = ((x3 * resolution)|0) / resolution;
723-
y3 = ((y3 * resolution)|0) / resolution;
724-
}
725-
726674
vertexViewF32[vertexOffset + 0] = x0;
727675
vertexViewF32[vertexOffset + 1] = y0;
728676
vertexViewU32[vertexOffset + 2] = bTint;
@@ -816,7 +764,6 @@ var FlatTintPipeline = new Class({
816764
var mvd = src * cmb + srd * cmd;
817765
var mve = sre * cma + srf * cmc + cme;
818766
var mvf = sre * cmb + srf * cmd + cmf;
819-
var roundPixels = camera.roundPixels;
820767

821768
var pathArrayIndex;
822769
var pathArrayLength;
@@ -911,8 +858,7 @@ var FlatTintPipeline = new Class({
911858

912859
/* Transform */
913860
mva, mvb, mvc, mvd, mve, mvf,
914-
currentMatrix,
915-
roundPixels
861+
currentMatrix
916862
);
917863
}
918864
break;
@@ -937,8 +883,7 @@ var FlatTintPipeline = new Class({
937883
/* Transform */
938884
mva, mvb, mvc, mvd, mve, mvf,
939885
path === this._lastPath,
940-
currentMatrix,
941-
roundPixels
886+
currentMatrix
942887
);
943888
}
944889
break;
@@ -959,8 +904,7 @@ var FlatTintPipeline = new Class({
959904

960905
/* Transform */
961906
mva, mvb, mvc, mvd, mve, mvf,
962-
currentMatrix,
963-
roundPixels
907+
currentMatrix
964908
);
965909

966910
cmdIndex += 4;
@@ -984,8 +928,7 @@ var FlatTintPipeline = new Class({
984928

985929
/* Transform */
986930
mva, mvb, mvc, mvd, mve, mvf,
987-
currentMatrix,
988-
roundPixels
931+
currentMatrix
989932
);
990933

991934
cmdIndex += 6;
@@ -1010,8 +953,7 @@ var FlatTintPipeline = new Class({
1010953

1011954
/* Transform */
1012955
mva, mvb, mvc, mvd, mve, mvf,
1013-
currentMatrix,
1014-
roundPixels
956+
currentMatrix
1015957
);
1016958

1017959
cmdIndex += 6;

0 commit comments

Comments
 (0)