Skip to content

Commit

Permalink
FlxGroup cameras again, this time without breaking FlxSpriteGroup (#2232
Browse files Browse the repository at this point in the history
)

closes #2229
  • Loading branch information
JoeCreates authored and Gama11 committed Aug 29, 2019
1 parent b6acc33 commit 1063137
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions flixel/FlxCamera.hx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class FlxCamera extends FlxBasic
/**
* Which cameras a `FlxBasic` uses to be drawn on when nothing else has been specified.
* By default, this is just a reference to `FlxG.cameras.list` / all cameras, but it can be very useful to change.
* This may be temporarily modified during a `draw` call.
*/
public static var defaultCameras:Array<FlxCamera>;

Expand Down
10 changes: 9 additions & 1 deletion flixel/group/FlxGroup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,13 @@ class FlxTypedGroup<T:FlxBasic> extends FlxBasic
{
var i:Int = 0;
var basic:FlxBasic = null;


var oldDefaultCameras = FlxCamera.defaultCameras;
if (cameras != null)
{
FlxCamera.defaultCameras = cameras;
}

while (i < length)
{
basic = members[i++];
Expand All @@ -189,6 +195,8 @@ class FlxTypedGroup<T:FlxBasic> extends FlxBasic
basic.draw();
}
}

FlxCamera.defaultCameras = oldDefaultCameras;
}

/**
Expand Down

1 comment on commit 1063137

@filipp8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know why but this breaks on mobile, both android/ios, and seems to be working on desktop (tested only on neko).
I think it is something wrong with zoom level.
I have three buttons on the top of my screen acting as toolbar and I trigger those buttons while tapping very far from them.

I have a 3 camera setup: bgCamera, fieldCamera and hudCamera.
I add every camera to FlxG.cameras and then set FlxCamera.defaultCameras = [Reg.hudCamera];
The problem is only present on hudCamera as the buttons with wrong behavior are shown in this camera.

The commit before this is working fine.

Please sign in to comment.