Skip to content

Commit 37701b0

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 0b684e5 + ef136f6 commit 37701b0

72 files changed

Lines changed: 2261 additions & 1057 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ env:
1111
- TERM=dumb
1212

1313
script:
14-
- yarn install
15-
- yarn run lint
16-
- yarn run build
14+
- npm install
15+
- npm run lint
16+
- npm run build

CHANGELOG.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,49 @@
66

77
* The Phaser 3 Labs has gained a nifty 'search' feature box thanks to @NemoStein - it allows you to filter out the example categories.
88
* We've added a Mask component, which is available on nearly all Game Objects. It includes the methods `setMask`, `clearMask`, `createBitmapMask` and `createGeometryMask`.
9+
* CanvasTexture is a new extension of the Texture object specifically created for when you've got a Canvas element as the backing source of the texture that you wish to draw to programmatically using the Canvas API. This was possible in previous versions, as a Texture object supported having a Canvas as its source, but we've streamlined the process and made it a lot easier for you to refresh the resulting WebGLTexture on the GPU. To create a CanvasTexture just call the `TextureManager.createCanvas` method as before, only this time you'll get a CanvasTexture back which has helper properties and methods. See the complete JSDocs for more details.
10+
* RandomDataGenerator has a new method: `shuffle` which allows you to shuffle an array using the current RNG seed (thanks @wtravO)
911

1012
### Updates
1113

1214
* If you're using Webpack with Phaser you'll need to update your config to match our new one.
1315
* We've swapped use of the Webpack DefinePlugin so instead of setting a global flag for the compilation of the Canvas and WebGL renderers, we now use a typeof check instead. This means you should now be able to ingest the Phaser source more easily outside of Webpack without having to define any global vars first (thanks @tgrajewski)
1416
* Under Webpack we still use the raw-loader to import our shader source, but outside of Webpack we now use `require.extensions` to load the shader source via fs. This should allow you to bundle Phaser with packages other than Webpack more easily (thanks @tgrajewski)
15-
* The Texture Manager will now emit an `addtexture` event whenever you add a new texture to it, which includes when you load images files from the Loader (as it automatically populates the Texture Manager). Once you receive an `addtexture` event you know the image is loaded and the texture is safe to be applied to a Game Object.
17+
* The Texture Manager will now emit an `addtexture` event whenever you add a new texture to it, which includes when you load image files from the Loader (as it automatically populates the Texture Manager). Once you receive an `addtexture` event you know the image is loaded and the texture is safe to be applied to a Game Object.
18+
* BitmapMask and GeometryMask both have new `destroy` methods which clear their references, freeing them for gc.
19+
* CanvasPool has a new argument `selfParent` which allows the canvas itself to be the parent key, used for later removal.
20+
* Frame has a new method `setSize` which allows you to set the frame x, y, width and height and have it update all of the internal properties automatically. This is now called directly in the constructor.
21+
* When a TextureSource is destroyed if it's got a canvas texture it's removed from the CanvasPool.
22+
* TextureManager.checkKey will check if a texture key is in-use and log a console error if it is and then return a boolean. This is now used extensively internally to prevent you from adding textures that already exist into the manager. If you wish to just check if a key is in use without the error, use the `TextureManager.exists` method as before.
23+
* TextureManager.remove will allow you to remove a texture from the manager. The texture is destroyed and it emits a `removetexture` event.
24+
* TextureSource has a new property `renderer` as it's used a lot internally and is useful if you extend the class.
25+
* TextureSource will now remove its respective WebGLTexture from the renderer when destroyed.
26+
* TextureSource will now automatically create a glTexture from its canvas if using one.
27+
* WebGLRenderer will now remove a GL texture from its local `nativeTextures` array when you call the `deleteTexture` method.
28+
* The BaseCache has a new method `exists` that will return a boolean if an entry for the given key exists in the cache or not.
29+
* Loader.File has a new argument in its constructor which is an instance of the LoaderPlugin. It stores this in the `loader` property. It also has a new property `cache` which is a reference to the cache that the file type will be stored in.
30+
* Loader.File has a new method `hasCacheConflict` which checks if a key matching the one used by this file exists in the target Cache or not.
31+
* Loader.File has a new method `addToCache` which will add the file to its target cache and then emit a `filecomplete` event, passing its key and a reference to itself to the listener (thanks to @kalebwalton for a related PR)
32+
* LoaderPlugin has a new property `cacheManager` which is a reference to the global game cache and is used by the File Types.
33+
* LoaderPlugin has a new property `textureManager` which is a reference to the global Texture Manager and is used by the File Types.
34+
* LoaderPlugin will now check to see if loading a file would cache a cache conflict or not, and prevent it if it will.
35+
* LoaderPlugin now passes off processing of the final file data to the file itself, which will now self-add itself to its target cache.
1636

1737
### Bug Fixes
1838

1939
* DataManagerPlugin would throw an error on Game.destroy if you had any Scenes in the Scene Manager had not been run. Fix #3596 (thanks @kuoruan)
40+
* If you created a Game with no Scenes defined, and then added one via `Game.scene.add` and passed in a data object, the data would be ignored when starting the Scene.
41+
* Adding a Group with an array of children in the constructor was broken since 3.5. Fix #3612 (thanks @fariazz @samme)
42+
* Fix ParticleEmitter toJSON output, it was missing the `angle` property and the Emitter Ops were being cast wrong (thanks @samme)
43+
* Fixed loading normals with multi image load (thanks @iamchristopher)
44+
* Array.AddAt would fail if it branched to the fast-path within a Container due to an invalid property. Fix #3617 (thanks @poasher)
45+
* Polygon.setTo would fail if given an array of arrays as a list of points. Fix #3619 (thanks @PaulTodd)
2046

2147
### Examples, Documentation and TypeScript
2248

2349
My thanks to the following for helping with the Phaser 3 Examples, Docs and TypeScript definitions, either by reporting errors, fixing them or helping author the docs:
2450

25-
@wtravO
51+
@wtravO @Fabadiculous @zilbuz @samme @iamchristopher
2652

2753
## Version 3.6.0 - Asuna - 19th April 2018
2854

src/cache/BaseCache.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ var BaseCache = new Class({
8383

8484
/**
8585
* Checks if this cache contains an item matching the given key.
86+
* This performs the same action as `BaseCache.exists`.
8687
*
8788
* @method Phaser.Cache.BaseCache#has
8889
* @since 3.0.0
@@ -96,6 +97,22 @@ var BaseCache = new Class({
9697
return this.entries.has(key);
9798
},
9899

100+
/**
101+
* Checks if this cache contains an item matching the given key.
102+
* This performs the same action as `BaseCache.has` and is called directly by the Loader.
103+
*
104+
* @method Phaser.Cache.BaseCache#exists
105+
* @since 3.7.0
106+
*
107+
* @param {string} key - The unique key of the item to be checked in this cache.
108+
*
109+
* @return {boolean} Returns `true` if the cache contains an item matching the given key, otherwise `false`.
110+
*/
111+
exists: function (key)
112+
{
113+
return this.entries.has(key);
114+
},
115+
99116
/**
100117
* Gets an item from this cache based on the given key.
101118
*

src/display/canvas/CanvasPool.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ var CanvasPool = function ()
3636
* @param {integer} [width=1] - The width of the Canvas.
3737
* @param {integer} [height=1] - The height of the Canvas.
3838
* @param {integer} [canvasType=Phaser.CANVAS] - The type of the Canvas. Either `Phaser.CANVAS` or `Phaser.WEBGL`.
39+
* @param {boolean} [selfParent=false] - Use the generated Canvas element as the parent?
3940
*
4041
* @return {HTMLCanvasElement} [description]
4142
*/
42-
var create = function (parent, width, height, canvasType)
43+
var create = function (parent, width, height, canvasType, selfParent)
4344
{
4445
if (width === undefined) { width = 1; }
4546
if (height === undefined) { height = 1; }
4647
if (canvasType === undefined) { canvasType = CONST.CANVAS; }
48+
if (selfParent === undefined) { selfParent = false; }
4749

4850
var canvas;
4951
var container = first(canvasType);
@@ -70,6 +72,11 @@ var CanvasPool = function ()
7072
canvas = container.canvas;
7173
}
7274

75+
if (selfParent)
76+
{
77+
container.parent = canvas;
78+
}
79+
7380
canvas.width = width;
7481
canvas.height = height;
7582

src/display/mask/BitmapMask.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,24 @@ var BitmapMask = new Class({
191191
postRenderCanvas: function ()
192192
{
193193
// NOOP
194+
},
195+
196+
/**
197+
* Destroys this BitmapMask and nulls any references it holds.
198+
*
199+
* Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it,
200+
* so be sure to call `clearMask` on any Game Object using it, before destroying it.
201+
*
202+
* @method Phaser.Display.Masks.BitmapMask#destroy
203+
* @since 3.6.1
204+
*/
205+
destroy: function ()
206+
{
207+
this.bitmapMask = null;
208+
this.mainTexture = null;
209+
this.maskTexture = null;
210+
this.mainFramebuffer = null;
211+
this.maskFramebuffer = null;
194212
}
195213

196214
});

src/display/mask/GeometryMask.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,20 @@ var GeometryMask = new Class({
131131
postRenderCanvas: function (renderer)
132132
{
133133
renderer.currentContext.restore();
134+
},
135+
136+
/**
137+
* Destroys this GeometryMask and nulls any references it holds.
138+
*
139+
* Note that if a Game Object is currently using this mask it will _not_ automatically detect you have destroyed it,
140+
* so be sure to call `clearMask` on any Game Object using it, before destroying it.
141+
*
142+
* @method Phaser.Display.Masks.GeometryMask#destroy
143+
* @since 3.6.1
144+
*/
145+
destroy: function ()
146+
{
147+
this.geometryMask = null;
134148
}
135149

136150
});

src/gameobjects/components/GetBounds.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ var GetBounds = {
196196
* @method Phaser.GameObjects.Components.GetBounds#getBounds
197197
* @since 3.0.0
198198
*
199-
* @generic {Phaser.Math.Vector2} O - [output,$return]
199+
* @generic {Phaser.Geom.Rectangle} O - [output,$return]
200200
*
201201
* @param {(Phaser.Geom.Rectangle|object)} [output] - An object to store the values in. If not provided a new Rectangle will be created.
202202
*

src/gameobjects/components/Mask.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,19 @@ var Mask = {
5555
* @method Phaser.GameObjects.Components.Mask#clearMask
5656
* @since 3.6.2
5757
*
58+
* @param {boolean} [destroyMask=false] - Destroy the mask before clearing it?
59+
*
5860
* @return {Phaser.GameObjects.GameObject} This Game Object instance.
5961
*/
60-
clearMask: function ()
62+
clearMask: function (destroyMask)
6163
{
64+
if (destroyMask === undefined) { destroyMask = false; }
65+
66+
if (destroyMask)
67+
{
68+
this.mask.destroy();
69+
}
70+
6271
this.mask = null;
6372

6473
return this;

src/gameobjects/components/Texture.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var Texture = {
2020
* The Texture this Game Object is using to render with.
2121
*
2222
* @name Phaser.GameObjects.Components.Texture#texture
23-
* @type {Phaser.Textures.Texture}
23+
* @type {Phaser.Textures.Texture|Phaser.Textures.CanvasTexture}
2424
* @since 3.0.0
2525
*/
2626
texture: null,

src/gameobjects/graphics/Graphics.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ var Graphics = new Class({
11391139

11401140
if (sys.game.renderer.gl && texture)
11411141
{
1142-
texture.source[0].glTexture = sys.game.renderer.canvasToTexture(ctx.canvas, texture.source[0].glTexture, true, 0);
1142+
texture.source[0].glTexture = sys.game.renderer.canvasToTexture(ctx.canvas, texture.source[0].glTexture);
11431143
}
11441144
}
11451145

0 commit comments

Comments
 (0)