Applying text to a layer
Text is an important part of game development as it can be used to dynamically display point systems, tutorials, descriptions, and more. AndEngine also allows us to create text styles which suit individual game types better by specifying customized Font
objects. In this recipe, we're going to create a Text
object, which updates itself with the current system time as well as correct its position every time the length of the string grows or shrinks. This will prepare us for the use of Text
objects in cases where we need to display scores, time, and other non-specific dynamic string situations.
Getting ready…
Applying Text
objects to our Scene
object requires a working knowledge of AndEngine's font resources. Please perform the the recipe, Using AndEngine font resources in Chapter 1, Working with Entities, then proceed with the How to do it... section of this recipe. Refer to the class named ApplyingText
in the code bundle for this recipe's activity in code.