mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 23:20:59 +00:00
LightsManager.destroy
will now clear the lightPool
array when destroyed, where-as previously it didn't.
This commit is contained in:
parent
84968f502f
commit
1146e6f7a3
1 changed files with 19 additions and 13 deletions
|
@ -157,9 +157,9 @@ var LightsManager = new Class({
|
|||
|
||||
culledLights.length = 0;
|
||||
|
||||
for (var index = 0; index < length && culledLights.length < this.maxLights; index++)
|
||||
for (var i = 0; i < length && culledLights.length < this.maxLights; i++)
|
||||
{
|
||||
var light = lights[index];
|
||||
var light = lights[i];
|
||||
|
||||
cameraMatrix.transformPoint(light.x, light.y, point);
|
||||
|
||||
|
@ -170,7 +170,7 @@ var LightsManager = new Class({
|
|||
|
||||
if (distance < light.radius + cameraRadius)
|
||||
{
|
||||
culledLights.push(lights[index]);
|
||||
culledLights.push(lights[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,9 +197,9 @@ var LightsManager = new Class({
|
|||
var lights = this.lights;
|
||||
var length = lights.length;
|
||||
|
||||
for (var index = 0; index < length; ++index)
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
callback(lights[index]);
|
||||
callback(lights[i]);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -268,21 +268,25 @@ var LightsManager = new Class({
|
|||
*/
|
||||
addLight: function (x, y, radius, rgb, intensity)
|
||||
{
|
||||
if (x === undefined) { x = 0; }
|
||||
if (y === undefined) { y = 0; }
|
||||
if (radius === undefined) { radius = 100; }
|
||||
if (rgb === undefined) { rgb = 0xffffff; }
|
||||
if (intensity === undefined) { intensity = 1; }
|
||||
|
||||
var color = null;
|
||||
var light = null;
|
||||
|
||||
x = (x === undefined) ? 0.0 : x;
|
||||
y = (y === undefined) ? 0.0 : y;
|
||||
rgb = (rgb === undefined) ? 0xffffff : rgb;
|
||||
radius = (radius === undefined) ? 100.0 : radius;
|
||||
intensity = (intensity === undefined) ? 1.0 : intensity;
|
||||
|
||||
color = Utils.getFloatsFromUintRGB(rgb);
|
||||
|
||||
light = null;
|
||||
|
||||
if (this.lightPool.length > 0)
|
||||
var pool = this.lightPool;
|
||||
|
||||
if (pool.length > 0)
|
||||
{
|
||||
light = this.lightPool.pop();
|
||||
light = pool.pop();
|
||||
|
||||
light.set(x, y, radius, color[0], color[1], color[2], intensity);
|
||||
}
|
||||
else
|
||||
|
@ -350,6 +354,8 @@ var LightsManager = new Class({
|
|||
destroy: function ()
|
||||
{
|
||||
this.shutdown();
|
||||
|
||||
this.lightPool.length = 0;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue