I have a Flixel project with multiple FlxCamera
's. One of them is the main play area, and another is the radar display within the HUD to the right of the main area. I want to add a layer (FlxGroup
) to just the radar camera, and I also want to exclude my other layers from the radar camera so they don't randomly show up in the radar's area.
My question is, how do I tell the cameras to only show objects in certain FlxGroup
's?
Figured this out on my own. Each object needs to be given a reference to an
Array
containing references to theFlxCamera
objects you want it shown on, and this needs to happen (usually) when the object is first made. The first time aFlxObject
callsupdate()
, if itscameras
is null, it assignsFlxG.cameras
as a default, which means all of the active cameras will display the object.I did this by making a few static
Array
's in my Main class, one for each camera group, and then in the constructor for my various classes, I would set theircameras
variable to point to the correspondingArray
.The biggest frustration: Currently
FlxGroup
does not pass itscameras
on to its members. Hopefully this will be added into future versions of Flixel so thatFlxGroup
's can be assigned a camera group and have all their children also automatically assigned the same camera group.