1

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?

Mar
  • 7,765
  • 9
  • 48
  • 82

1 Answers1

2

Figured this out on my own. Each object needs to be given a reference to an Array containing references to the FlxCamera objects you want it shown on, and this needs to happen (usually) when the object is first made. The first time a FlxObject calls update(), if its cameras is null, it assigns FlxG.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 their cameras variable to point to the corresponding Array.

The biggest frustration: Currently FlxGroup does not pass its cameras on to its members. Hopefully this will be added into future versions of Flixel so that FlxGroup's can be assigned a camera group and have all their children also automatically assigned the same camera group.

Mar
  • 7,765
  • 9
  • 48
  • 82
  • +1. In your frustration you might consider visiting their [Contribute](http://flixel.org/contribute.html) page and suggesting less frustrating implementations that they could add. – Marty Nov 18 '11 at 00:16
  • Thanks for that link, I just submitted my suggestion. – Mar Nov 18 '11 at 06:24