Skip to content

Commit fdbdd81

Browse files
committed
Updated some docs, added the new renderHidden parameter for Canvas and updated the RenderTexture examples as a result.
1 parent 2c80778 commit fdbdd81

9 files changed

Lines changed: 83 additions & 53 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ Updates:
102102
* Tweens fire an onLoop event if they are set to repeat. onComplete is now only fired for the final repeat (or never if the repeat is infinite)
103103
* Pointer used to un-pause a paused game every time it was clicked/touched (this avoided some rogue browser plugins). Now only happens if Stage.disableVisibilityChange is true.
104104
* Input doesn't set the cursor to default if it's already set to none.
105+
* You can now collide a group against itself, to have all children collide, and bodies won't check against themselves (thanks cocoademon)
106+
* RenderTexture.render / renderXY has a new parameter: renderHidden, a boolean which will allow you to render Sprites even if their visible is set to false.
105107

106108

107109
Bug Fixes:

examples/display/render texture mirror.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ function create() {
2727

2828
function update() {
2929

30-
// This time we'll draw the ball sprite twice, in a mirror effect
31-
32-
texture.renderXY(ball, game.input.activePointer.x, game.input.activePointer.y, false);
33-
texture.renderXY(ball, game.input.activePointer.x, 600 - game.input.activePointer.y, false);
30+
if (!game.input.activePointer.position.isZero())
31+
{
32+
// This time we'll draw the ball sprite twice, in a mirror effect
33+
texture.renderXY(ball, game.input.activePointer.x, game.input.activePointer.y, false, true);
34+
texture.renderXY(ball, game.input.activePointer.x, 600 - game.input.activePointer.y, false, true);
35+
}
3436

3537
}

examples/display/render texture starfield.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ function update() {
6969
if (i == 0 || i == 100 || i == 200)
7070
{
7171
// If it's the first star of the layer then we clear the texture
72-
stars[i].texture.renderXY(star, stars[i].x, stars[i].y, true);
72+
stars[i].texture.renderXY(star, stars[i].x, stars[i].y, true, true);
7373
}
7474
else
7575
{
7676
// Otherwise just draw the star sprite where we need it
77-
stars[i].texture.renderXY(star, stars[i].x, stars[i].y, false);
77+
stars[i].texture.renderXY(star, stars[i].x, stars[i].y, false, true);
7878
}
7979
}
8080

examples/display/render texture trail.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ function create() {
2727

2828
function update() {
2929

30-
// Here we draw the mushroom sprite to the renderTexture at the pointer coordinates.
31-
// The 'false' parameter at the end tells it not to clear itself, causing the trail effect you see.
32-
texture.render(mushroom, game.input.activePointer.position, false);
30+
if (!game.input.activePointer.position.isZero())
31+
{
32+
// Here we draw the mushroom sprite to the renderTexture at the pointer coordinates.
33+
// The 'false' parameter 2nd from the end tells it not to clear itself, causing the trail effect you see.
34+
// The final 'true' parameter tells it to render sprites even with visible false set.
35+
texture.render(mushroom, game.input.activePointer.position, false, true);
36+
}
3337

3438
}

src/PixiPatch.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ PIXI.CanvasRenderer.prototype.render = function(stage)
2424

2525
this.context.setTransform(1, 0, 0, 1, 0, 0);
2626
this.context.clearRect(0, 0, this.width, this.height)
27-
this.renderDisplayObject(stage);
27+
this.renderDisplayObject(stage, false);
2828

2929
// Remove frame updates
3030
if (PIXI.Texture.frameUpdates.length > 0)
@@ -34,7 +34,9 @@ PIXI.CanvasRenderer.prototype.render = function(stage)
3434

3535
}
3636

37-
PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
37+
// @param {boolean} [renderHidden=false] - If true displayObjects that have their visible property set to false will still be rendered.
38+
39+
PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject, renderHidden)
3840
{
3941
// Once the display object hits this we can break the loop
4042
var testObject = displayObject.last._iNext;
@@ -44,7 +46,7 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
4446
{
4547
//transform = displayObject.worldTransform;
4648

47-
if (!displayObject.visible)
49+
if (!displayObject.visible && !renderHidden)
4850
{
4951
displayObject = displayObject.last._iNext;
5052
continue;

src/animation/Animation.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope
4343
this.name = name;
4444

4545
/**
46-
* @property {object} _frames
46+
* @property {array} _frames
4747
* @private
4848
*/
4949
this._frames = [];
@@ -60,7 +60,8 @@ Phaser.Animation = function (game, parent, name, frameData, frames, delay, loope
6060
this.looped = looped;
6161

6262
/**
63-
* @property {boolean} looped - The loop state of the Animation.
63+
* @property {boolean} killOnComplete - Should the parent of this Animation be killed when the animation completes?
64+
* @default
6465
*/
6566
this.killOnComplete = false;
6667

src/gameobjects/RenderTexture.js

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,19 @@ Phaser.RenderTexture.prototype.constructor = PIXI.RenderTexture;
7171
/**
7272
* This function will draw the display object to the texture. If the display object is a Group or has children it will
7373
* draw all children as well.
74-
*
75-
* @method render
74+
*
75+
* @method Phaser.RenderTexture#render
76+
* @memberof Phaser.RenderTexture
7677
* @param {DisplayObject} displayObject - The display object to render this texture on.
7778
* @param {Phaser.Point} [position] - Where to draw the display object.
7879
* @param {boolean} [clear=false] - If true the texture will be cleared before the displayObject is drawn.
80+
* @param {boolean} [renderHidden=false] - If true displayObjects that have their visible property set to false will still be rendered.
7981
*/
80-
Phaser.RenderTexture.prototype.render = function(displayObject, position, clear) {
82+
Phaser.RenderTexture.prototype.render = function(displayObject, position, clear, renderHidden) {
8183

8284
if (typeof position === 'undefined') { position = false; }
8385
if (typeof clear === 'undefined') { clear = false; }
86+
if (typeof renderHidden === 'undefined') { renderHidden = false; }
8487

8588
if (displayObject instanceof Phaser.Group)
8689
{
@@ -89,11 +92,11 @@ Phaser.RenderTexture.prototype.render = function(displayObject, position, clear)
8992

9093
if (PIXI.gl)
9194
{
92-
this.renderWebGL(displayObject, position, clear);
95+
this.renderWebGL(displayObject, position, clear, renderHidden);
9396
}
9497
else
9598
{
96-
this.renderCanvas(displayObject, position, clear);
99+
this.renderCanvas(displayObject, position, clear, renderHidden);
97100
}
98101

99102
}
@@ -102,29 +105,32 @@ Phaser.RenderTexture.prototype.render = function(displayObject, position, clear)
102105
* This function will draw the display object to the texture at the given x/y coordinates.
103106
* If the display object is a Group or has children it will draw all children as well.
104107
*
105-
* @method renderXY
108+
* @method Phaser.RenderTexture#renderXY
109+
* @memberof Phaser.RenderTexture
106110
* @param {DisplayObject} displayObject - The display object to render this texture on.
107111
* @param {number} x - The x coordinate to draw the display object at.
108112
* @param {number} y - The y coordinate to draw the display object at.
109113
* @param {boolean} [clear=false] - If true the texture will be cleared before the displayObject is drawn.
114+
* @param {boolean} [renderHidden=false] - If true displayObjects that have their visible property set to false will still be rendered.
110115
*/
111-
Phaser.RenderTexture.prototype.renderXY = function(displayObject, x, y, clear) {
116+
Phaser.RenderTexture.prototype.renderXY = function(displayObject, x, y, clear, renderHidden) {
112117

113118
this._tempPoint.x = x;
114119
this._tempPoint.y = y;
115120

116-
this.render(displayObject, this._tempPoint, clear);
121+
this.render(displayObject, this._tempPoint, clear, renderHidden);
117122

118123
}
119124

120125
/**
121-
* Initializes the webgl data for this texture
122-
*
123-
* @method initWebGL
124-
* @private
125-
*/
126-
Phaser.RenderTexture.prototype.initWebGL = function()
127-
{
126+
* Initializes the webgl data for this texture
127+
*
128+
* @method Phaser.RenderTexture#initWebGL
129+
* @memberof Phaser.RenderTexture
130+
* @private
131+
*/
132+
Phaser.RenderTexture.prototype.initWebGL = function() {
133+
128134
var gl = PIXI.gl;
129135
this.glFramebuffer = gl.createFramebuffer();
130136

@@ -160,7 +166,12 @@ Phaser.RenderTexture.prototype.initWebGL = function()
160166
// this.render = this.renderWebGL;
161167
}
162168

163-
169+
/**
170+
* Resizes the RenderTexture.
171+
*
172+
* @method Phaser.RenderTexture#resize
173+
* @memberof Phaser.RenderTexture
174+
*/
164175
Phaser.RenderTexture.prototype.resize = function(width, height)
165176
{
166177

@@ -186,11 +197,12 @@ Phaser.RenderTexture.prototype.resize = function(width, height)
186197
}
187198

188199
/**
189-
* Initializes the canvas data for this texture
190-
*
191-
* @method initCanvas
192-
* @private
193-
*/
200+
* Initializes the canvas data for this texture
201+
*
202+
* @method Phaser.RenderTexture#initCanvas
203+
* @memberof Phaser.RenderTexture
204+
* @private
205+
*/
194206
Phaser.RenderTexture.prototype.initCanvas = function()
195207
{
196208
this.renderer = new PIXI.CanvasRenderer(this.width, this.height, null, 0);
@@ -202,14 +214,17 @@ Phaser.RenderTexture.prototype.initCanvas = function()
202214
}
203215

204216
/**
205-
* This function will draw the display object to the texture.
206-
*
207-
* @method renderWebGL
208-
* @param displayObject {DisplayObject} The display object to render this texture on
209-
* @param clear {Boolean} If true the texture will be cleared before the displayObject is drawn
210-
* @private
211-
*/
212-
Phaser.RenderTexture.prototype.renderWebGL = function(displayObject, position, clear)
217+
* This function will draw the display object to the texture.
218+
*
219+
* @method Phaser.RenderTexture#renderWebGL
220+
* @memberof Phaser.RenderTexture
221+
* @private
222+
* @param {DisplayObject} displayObject - The display object to render this texture on.
223+
* @param {Phaser.Point} [position] - Where to draw the display object.
224+
* @param {boolean} [clear=false] - If true the texture will be cleared before the displayObject is drawn.
225+
* @param {boolean} [renderHidden=false] - If true displayObjects that have their visible property set to false will still be rendered.
226+
*/
227+
Phaser.RenderTexture.prototype.renderWebGL = function(displayObject, position, clear, renderHidden)
213228
{
214229
var gl = PIXI.gl;
215230

@@ -280,12 +295,15 @@ Phaser.RenderTexture.prototype.renderWebGL = function(displayObject, position, c
280295
/**
281296
* This function will draw the display object to the texture.
282297
*
283-
* @method renderCanvas
284-
* @param displayObject {DisplayObject} The display object to render this texture on
285-
* @param clear {Boolean} If true the texture will be cleared before the displayObject is drawn
286-
* @private
287-
*/
288-
Phaser.RenderTexture.prototype.renderCanvas = function(displayObject, position, clear)
298+
* @method Phaser.RenderTexture#renderCanvas
299+
* @memberof Phaser.RenderTexture
300+
* @private
301+
* @param {DisplayObject} displayObject - The display object to render this texture on.
302+
* @param {Phaser.Point} [position] - Where to draw the display object.
303+
* @param {boolean} [clear=false] - If true the texture will be cleared before the displayObject is drawn.
304+
* @param {boolean} [renderHidden=false] - If true displayObjects that have their visible property set to false will still be rendered.
305+
*/
306+
Phaser.RenderTexture.prototype.renderCanvas = function(displayObject, position, clear, renderHidden)
289307
{
290308
var children = displayObject.children;
291309

@@ -307,9 +325,8 @@ Phaser.RenderTexture.prototype.renderCanvas = function(displayObject, position,
307325
this.renderer.context.clearRect(0, 0, this.width, this.height);
308326
}
309327

310-
this.renderer.renderDisplayObject(displayObject);
328+
this.renderer.renderDisplayObject(displayObject, renderHidden);
311329

312330
this.renderer.context.setTransform(1, 0, 0, 1, 0, 0);
313331

314-
// PIXI.texturesToUpdate.push(this.baseTexture);
315332
}

src/input/Mouse.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ Phaser.Mouse = function (game) {
6868
this.pointerLock = new Phaser.Signal();
6969

7070
/**
71-
* @property {MouseEvent} event - The browser mouse event.
71+
* @property {MouseEvent} event - The browser mouse DOM event. Will be set to null if no mouse event has ever been received.
72+
* @default
7273
*/
7374
this.event = null;
7475

src/input/Touch.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ Phaser.Touch = function (game) {
6767
this.preventDefault = true;
6868

6969
/**
70-
* @property {TouchEvent} event - The browser touch event.
70+
* @property {TouchEvent} event - The browser touch DOM event. Will be set to null if no touch event has ever been received.
71+
* @default
7172
*/
7273
this.event = null;
7374

0 commit comments

Comments
 (0)