如何在 HaxeFlixel 或 Unity 中制作这种灯光效果?

How to make this lighting effect in HaxeFlixel or Unity?

如何在 HaxeFlixel 或 Unity 中创建这种灯光效果?

我将告诉您在这个特定案例中它是如何创建的。这个问题非常广泛,在 Unity 和 HaxeFlixel 中创建灯光效果的方法有很多。

图像是 Deepnight 的游戏 Beneath the City 的图像,可在他的 website. The game uses haxe although not with HaxeFlixel. It's deepnight's personal engine that works with the flash target. The source code is available here. The class where lighting takes place is in src/Level.hx and more specifically in the renderLights method. From what I gather, a light layer is layered above the sprites of the level. This layer (or bitmap data) has lights drawn as rectangles on it. This layer is then blurred, so that the lights don't appear as solid rectangles, but as faded blurs of spreading light. This takes place with flash blur filters. Blend modes are used to make the light Add in luminosity. A dark mask is then layered above the blur layer, presumably to prevent light in certain locations, such as in the fog of the game. (?). This all takes place between lines 208 and 248.

上访问

这个游戏确实有华丽的视觉效果,但灯光超越了最初的模糊灯光。粒子在游戏中四处漂浮,真正增加了灯光的美感。

他就是这样做的。你怎么做取决于你。对于 HaxeFlixel,我会首先考虑替代方案,例如 this geometric lighting or this method of applying lighting to scenes, which looks closer to screenshot or even a very simple circle based lighting alternative。搜索 Unity 2D lighting 会出现很多选项。

关于如何解决这个问题,您有很多选择。我没有通过直接教程回答这个问题,因为问题不在代码级别。