Was looking around for a good example of displaying dynamic text on the screen. All of the examples use text defined in the config file. Is there a simple example of changing text such as a digital clock or something? That'd sure be a nice example program. I'm still fumbling around here...
Comments
Then you create a clock and attach register a function that will be called everytime it ticks (notice that it is not 100% precise, so in this case I set the tick speed to 0.9, the error is very small, but since you want to update a timer, setting it for one second would eventually lead it skipping a second).
Finally, you update the timer in the function:
just update the Live.Score config value and the text object will be updated
Sausage just posted a couple of tutorials on the wiki and there's some related material on the orx-dev group as well, more details and links here: http://orx-project.org/component/content/article/1-orx/89-commands-and-timeline-tutorials
Lastly, here are a couple of precisions on previous answers:
- If you ever need a 1-second tick clock, orx has one internally that can be retrieved by users using orxCLOCK_TYPE_SECOND instead of orxCLOCK_TYPE_USER/orxCLOCK_TYPE_CORE. Orx uses it to compute framerate but it's there for anyone who needs it.
- If you need a periodical call, you can also request a timer based on an already existing clock using orxClock_AddTimer()/orxClock_AddGlobalTimer(). This is usually a bit easier and more flexible than creating a brand new clock. Also a timer can be modified/cancelled/re-added from within the timer callback itself, which can come in handy (I'm using this to simulate keypress repetition in the console, for example, where the initial delay is different than subsequent ones).
- Back to the original clock simulation example, here's a pure config-based version that uses a 1-second tick resolution:
In config:
Open the console (by pressing backquote at runtime), and type:
The score and ball counters are digital text that is defined in the config but changed in code.
This sounds pretty much what you are trying to do.
I created a bitmap LED font in Blender & Gimp:
Then in the config, create a Font definition which sets the image to use, what the characters are to mapped to, and what the spacing and character size is:
The CharacterSize and CharacterSpacing helps the Orx engine map a real character to the visual portion within the image.
Then create a Text which uses LedFont, and sets the initial string to something:
Next, make a Graphic that uses the Text:
And like all Objects, make one that uses the Graphic:
Then, as others have already said, you can change the text in code at any time on the Object to display text using the characters defined in your Font / CharacterList:
Hopefully this is what you are after. Essentially, you need to make your font into a bitmap and map to characters. Then change the value in code to your heart's content.