Flixel - 如何使 FlxGroups 仅出现在一台 FlxCamera 上?

发布于 2024-12-16 01:00:24 字数 216 浏览 0 评论 0原文

我有一个包含多个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤城病女 2024-12-23 01:00:24

我自己想出了这个办法。每个对象都需要获得一个对 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 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文