O'Reilly logo

Libgdx Cross-platform Game Development Cookbook by Alberto Cejas Sánchez, David Saltares Márquez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dynamic font effects using distance fields

Interestingly, the distance fields technique from the previous recipe can be exploited to achieve font effects dynamically, such as outlines, glows, and drop shadows. Can this technique get any more awesome?

No need to generate yet another font texture with prebaked effects; you can turn them off or on as well as tweak and tween their parameters completely at runtime. Consequently, you will be able to achieve a much richer and engaging experience. Moreover, the performance penalty is negligible—you can go crazy!

Just keep in mind that every time you set a shader on a SpriteBatch object, the latter is automatically flushed with the consequent draw call.

In this recipe, we will start off with an existing distance ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required