Flixel - 如何使 FlxGroups 仅出现在一台 FlxCamera 上?
我有一个包含多个 FlxCamera
的 Flixel 项目。其中之一是主要游戏区域,另一个是主区域右侧 HUD 内的雷达显示屏。我想仅向雷达摄像头添加一个图层 (FlxGroup
),并且我还想从雷达摄像头中排除其他图层,这样它们就不会随机出现在雷达区域中。
我的问题是,如何告诉相机仅显示某些 FlxGroup
中的对象?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己想出了这个办法。每个对象都需要获得一个对
Array
的引用,其中包含对您希望其显示的FlxCamera
对象的引用,并且(通常)需要在该对象第一次出现时执行此操作制成。FlxObject
第一次调用update()
时,如果其cameras
为 null,则会将FlxG.cameras
分配为默认值,这意味着所有活动摄像机都将显示该对象。我通过在主类中创建一些静态数组(每个相机组一个)来实现这一点,然后在各个类的构造函数中设置它们的相机> 变量指向相应的
Array
。最大的挫折:目前
FlxGroup
并未将其相机
传递给其成员。希望这将被添加到 Flixel 的未来版本中,以便可以为FlxGroup
分配一个摄像头组,并为其所有子项自动分配相同的摄像头组。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.