Skip to content

Commit 79d873f

Browse files
committed
If you are using CocoonJS, please set your game render type to CANVAS and not WEBGL or AUTO. You should also disable any of the ScaleManager screen resizing or margin setting code. By default in this mode CocoonJS will now set 'screencanvas=true' which helps with performance significantly.
1 parent 09915eb commit 79d873f

3 files changed

Lines changed: 38 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Version 2.1.0 - "Cairhien" - -in development-
6969
### New Features
7070

7171
* Updated to [p2.js 0.6.0](https://github.com/schteppe/p2.js/commit/d1c7a340c42e4d5d1d939fba5fd13c5e49d6abd2) - this was an API breaking change, so please see the p2.js section of this change log specifically if you're using p2 in your game.
72+
* If you are using CocoonJS, please set your game render type to CANVAS and not WEBGL or AUTO. You should also disable any of the ScaleManager screen resizing or margin setting code. By default in this mode CocoonJS will now set 'screencanvas=true' which helps with performance significantly.
7273
* Ninja Physics is no longer included in the build files by default. Not enough people were using it, and not enough contributions were coming in to help polish it up, so we've saved the space and removed it. It's still available in the grunt build files if you require it, but we're deprecating it from the core library at this time. It will make a return in Phaser3 when we move to a modular class system.
7374
* ScaleManager has a new scaleMode called `RESIZE` which will tell Phaser to track the size of the parent container (either a dom element or the browser window if none given) and set the canvas size to match it. If the parent changes size the canvas will resize as well, keeping a 1:1 pixel ratio. There is also a new ScaleManager.setResizeCallback method which will let you define your own function to handle resize events from the game, such as re-positioning sprites for a fluid responsive layout (#642)
7475
* The width and height given to the Phaser.Game constructor can now be numbers or strings in which case the value is treated as a percentage. For example a value of "100%" for the width and height will tell Phaser to size the game to match the parent container dimensions exactly (or the browser window if no parent is given). Equally a size of "50%" would tell it to be half the size of the parent. The values are retained even through resize events, allowing it to maintain a percentage size based on the parent even as it updates.

src/core/Game.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,15 @@ Phaser.Game.prototype = {
597597

598598
if (this.device.cocoonJS)
599599
{
600-
// Some issue related to scaling arise with Cocoon using screencanvas and webgl renderer.
601-
// Disabling by default
602-
this.canvas.screencanvas = false;
600+
if (this.renderType === Phaser.CANVAS)
601+
{
602+
this.canvas.screencanvas = true;
603+
}
604+
else
605+
{
606+
// Some issue related to scaling arise with Cocoon using screencanvas and webgl renderer.
607+
this.canvas.screencanvas = false;
608+
}
603609
}
604610

605611
if (this.renderType === Phaser.HEADLESS || this.renderType === Phaser.CANVAS || (this.renderType === Phaser.AUTO && this.device.webGL === false))
@@ -630,7 +636,7 @@ Phaser.Game.prototype = {
630636
if (this.renderType !== Phaser.HEADLESS)
631637
{
632638
this.stage.smoothed = this.antialias;
633-
639+
634640
Phaser.Canvas.addToDOM(this.canvas, this.parent, false);
635641
Phaser.Canvas.setTouchAction(this.canvas);
636642
}

src/math/Math.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,22 @@ Phaser.Math = {
339339
return Math.atan2(y2 - y1, x2 - x1);
340340
},
341341

342+
/**
343+
* Find the angle of a segment from (x1, y1) -> (x2, y2).
344+
* Note that the difference between this method and Math.angleBetween is that this assumes the y coordinate travels
345+
* down the screen.
346+
*
347+
* @method Phaser.Math#angleBetweenY
348+
* @param {number} x1
349+
* @param {number} y1
350+
* @param {number} x2
351+
* @param {number} y2
352+
* @return {number}
353+
*/
354+
angleBetweenY: function (x1, y1, x2, y2) {
355+
return Math.atan2(x2 - x1, y2 - y1);
356+
},
357+
342358
/**
343359
* Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y).
344360
* @method Phaser.Math#angleBetweenPoints
@@ -350,6 +366,17 @@ Phaser.Math = {
350366
return Math.atan2(point2.y - point1.y, point2.x - point1.x);
351367
},
352368

369+
/**
370+
* Find the angle of a segment from (point1.x, point1.y) -> (point2.x, point2.y).
371+
* @method Phaser.Math#angleBetweenPointsY
372+
* @param {Phaser.Point} point1
373+
* @param {Phaser.Point} point2
374+
* @return {number}
375+
*/
376+
angleBetweenPointsY: function (point1, point2) {
377+
return Math.atan2(point2.x - point1.x, point2.y - point1.y);
378+
},
379+
353380
/**
354381
* Reverses an angle.
355382
* @method Phaser.Math#reverseAngle

0 commit comments

Comments
 (0)