Skip to content

Commit f4259de

Browse files
committed
DOMElementFactory, ExternFactory, ParticleManagerFactor, RopeFactory and SpriteFactory all no longer add the objects to the Update List, this is now handled by the ADDED events instead.
1 parent 7b83d31 commit f4259de

5 files changed

Lines changed: 14 additions & 26 deletions

File tree

src/gameobjects/domelement/DOMElementFactory.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,51 @@ var GameObjectFactory = require('../GameObjectFactory');
99

1010
/**
1111
* DOM Element Game Objects are a way to control and manipulate HTML Elements over the top of your game.
12-
*
12+
*
1313
* In order for DOM Elements to display you have to enable them by adding the following to your game
1414
* configuration object:
15-
*
15+
*
1616
* ```javascript
1717
* dom {
1818
* createContainer: true
1919
* }
2020
* ```
21-
*
21+
*
2222
* When this is added, Phaser will automatically create a DOM Container div that is positioned over the top
2323
* of the game canvas. This div is sized to match the canvas, and if the canvas size changes, as a result of
2424
* settings within the Scale Manager, the dom container is resized accordingly.
25-
*
25+
*
2626
* You can create a DOM Element by either passing in DOMStrings, or by passing in a reference to an existing
2727
* Element that you wish to be placed under the control of Phaser. For example:
28-
*
28+
*
2929
* ```javascript
3030
* this.add.dom(x, y, 'div', 'background-color: lime; width: 220px; height: 100px; font: 48px Arial', 'Phaser');
3131
* ```
32-
*
32+
*
3333
* The above code will insert a div element into the DOM Container at the given x/y coordinate. The DOMString in
3434
* the 4th argument sets the initial CSS style of the div and the final argument is the inner text. In this case,
3535
* it will create a lime colored div that is 220px by 100px in size with the text Phaser in it, in an Arial font.
36-
*
36+
*
3737
* You should nearly always, without exception, use explicitly sized HTML Elements, in order to fully control
3838
* alignment and positioning of the elements next to regular game content.
39-
*
39+
*
4040
* Rather than specify the CSS and HTML directly you can use the `load.html` File Loader to load it into the
4141
* cache and then use the `createFromCache` method instead. You can also use `createFromHTML` and various other
4242
* methods available in this class to help construct your elements.
43-
*
43+
*
4444
* Once the element has been created you can then control it like you would any other Game Object. You can set its
4545
* position, scale, rotation, alpha and other properties. It will move as the main Scene Camera moves and be clipped
4646
* at the edge of the canvas. It's important to remember some limitations of DOM Elements: The obvious one is that
4747
* they appear above or below your game canvas. You cannot blend them into the display list, meaning you cannot have
4848
* a DOM Element, then a Sprite, then another DOM Element behind it.
49-
*
49+
*
5050
* They also cannot be enabled for input. To do that, you have to use the `addListener` method to add native event
5151
* listeners directly. The final limitation is to do with cameras. The DOM Container is sized to match the game canvas
5252
* entirely and clipped accordingly. DOM Elements respect camera scrolling and scrollFactor settings, but if you
5353
* change the size of the camera so it no longer matches the size of the canvas, they won't be clipped accordingly.
54-
*
54+
*
5555
* Also, all DOM Elements are inserted into the same DOM Container, regardless of which Scene they are created in.
56-
*
56+
*
5757
* DOM Elements are a powerful way to align native HTML with your Phaser Game Objects. For example, you can insert
5858
* a login form for a multiplayer game directly into your title screen. Or a text input box for a highscore table.
5959
* Or a banner ad from a 3rd party service. Or perhaps you'd like to use them for high resolution text display and
@@ -78,7 +78,6 @@ GameObjectFactory.register('dom', function (x, y, element, style, innerText)
7878
var gameObject = new DOMElement(this.scene, x, y, element, style, innerText);
7979

8080
this.displayList.add(gameObject);
81-
this.updateList.add(gameObject);
8281

8382
return gameObject;
8483
});

src/gameobjects/extern/ExternFactory.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ GameObjectFactory.register('extern', function ()
2222
var extern = new Extern(this.scene);
2323

2424
this.displayList.add(extern);
25-
this.updateList.add(extern);
2625

2726
return extern;
2827
});

src/gameobjects/particles/ParticleManagerFactory.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@ var ParticleEmitterManager = require('./ParticleEmitterManager');
2323
*/
2424
GameObjectFactory.register('particles', function (key, frame, emitters)
2525
{
26-
var manager = new ParticleEmitterManager(this.scene, key, frame, emitters);
27-
28-
this.displayList.add(manager);
29-
this.updateList.add(manager);
30-
31-
return manager;
26+
return this.displayList.add(new ParticleEmitterManager(this.scene, key, frame, emitters));
3227
});
3328

3429
// When registering a factory function 'this' refers to the GameObjectFactory context.

src/gameobjects/rope/RopeFactory.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@ if (typeof WEBGL_RENDERER)
3131
{
3232
GameObjectFactory.register('rope', function (x, y, texture, frame, points, horizontal, colors, alphas)
3333
{
34-
var rope = new Rope(this.scene, x, y, texture, frame, points, horizontal, colors, alphas);
35-
36-
this.displayList.add(rope);
37-
38-
return this.updateList.add(rope);
34+
return this.displayList.add(new Rope(this.scene, x, y, texture, frame, points, horizontal, colors, alphas));
3935
});
4036
}
4137

src/gameobjects/sprite/SpriteFactory.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ GameObjectFactory.register('sprite', function (x, y, key, frame)
2727
var sprite = new Sprite(this.scene, x, y, key, frame);
2828

2929
this.displayList.add(sprite);
30-
this.updateList.add(sprite);
3130

3231
return sprite;
3332
});

0 commit comments

Comments
 (0)