Skip to content

Commit dc92526

Browse files
committed
Added the new renderList property and addToRenderList method
1 parent 5481a64 commit dc92526

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

src/cameras/2d/Camera.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,38 @@ var Camera = new Class({
206206
* @since 3.0.0
207207
*/
208208
this._follow = null;
209+
210+
/**
211+
* This array is populated with all of the Game Objects that this Camera has rendered
212+
* in the previous (or current, depending on when you inspect it) frame.
213+
*
214+
* It is cleared at the start of `Camera.preUpdate`, or if the Camera is destroyed.
215+
*
216+
* You should not modify this array as it is used internally by the input system,
217+
* however you can read it as required. Note that Game Objects may appear in this
218+
* list multiple times if they belong to multiple non-exclusive Containers.
219+
*
220+
* @name Phaser.Cameras.Scene2D.Camera#renderList
221+
* @type {Phaser.GameObjects.GameObject[]}
222+
* @since 3.52.0
223+
*/
224+
this.renderList = [];
225+
},
226+
227+
/**
228+
* Adds the given Game Object to this cameras render list.
229+
*
230+
* This is invoked during the rendering stage. Only objects that are actually rendered
231+
* will appear in the render list.
232+
*
233+
* @method Phaser.Cameras.Scene2D.Camera#addToRenderList
234+
* @since 3.52.0
235+
*
236+
* @param {Phaser.GameObjects.GameObject} child - The Game Object to add to the render list.
237+
*/
238+
addToRenderList: function (child)
239+
{
240+
this.renderList.push(child);
209241
},
210242

211243
/**
@@ -494,6 +526,8 @@ var Camera = new Class({
494526
*/
495527
preRender: function ()
496528
{
529+
this.renderList.length = 0;
530+
497531
var width = this.width;
498532
var height = this.height;
499533

@@ -793,6 +827,8 @@ var Camera = new Class({
793827

794828
BaseCamera.prototype.destroy.call(this);
795829

830+
this.renderList = [];
831+
796832
this._follow = null;
797833

798834
this.deadzone = null;

0 commit comments

Comments
 (0)