Skip to content

Commit

Permalink
FlxG.cameras: fix reset() not removing all cameras (#2016)
Browse files Browse the repository at this point in the history
Regression from edf93b5.
  • Loading branch information
Leonid Vakulenko authored and Gama11 committed Dec 26, 2016
1 parent 000bac9 commit 1c714ba
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
10 changes: 4 additions & 6 deletions flixel/system/frontEnds/CameraFrontEnd.hx
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,9 @@ class CameraFrontEnd
*/
public function reset(?NewCamera:FlxCamera):Void
{
for (camera in list)
remove(camera);

list.splice(0, list.length);

while (list.length > 0)
remove(list[0]);

if (NewCamera == null)
NewCamera = new FlxCamera(0, 0, FlxG.width, FlxG.height);

Expand Down Expand Up @@ -295,4 +293,4 @@ class CameraFrontEnd

return Color;
}
}
}
4 changes: 2 additions & 2 deletions tests/unit/src/FlxTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class FlxTest

public function new() {}

@After
@:access(flixel)
@AfterClass
function afterClass()
function after()
{
FlxG.game.getTimer = function()
{
Expand Down
14 changes: 13 additions & 1 deletion tests/unit/src/flixel/system/frontEnds/CameraFrontEndTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package flixel.system.frontEnds;
import flixel.FlxCamera;
import massive.munit.Assert;

class CameraFrontEndTest
class CameraFrontEndTest extends FlxTest
{
@Test
public function testCameraAdded()
Expand Down Expand Up @@ -50,4 +50,16 @@ class CameraFrontEndTest

FlxG.cameras.cameraResized.removeAll();
}

@Test
function testResetCameras()
{
Assert.areEqual(1, FlxG.cameras.list.length);

FlxG.cameras.add(new FlxCamera());
Assert.areEqual(2, FlxG.cameras.list.length);

FlxG.cameras.reset();
Assert.areEqual(1, FlxG.cameras.list.length);
}
}

0 comments on commit 1c714ba

Please sign in to comment.