Optimizing Sprite Font usage

From the Asset Store
Creepy Sprite Font suitable font for your Dark/Horror/Halloween games.
  • I'm learning to use Construct 3, and using Sprite Fonts for the first time to create custom fonts, I had a doubt regarding the optimization of these objects (I would like to use them in the best possible way avoiding unnecessary actions).

    I've noticed that at the creation of each SpriteFont object, it is necessary to load an associated sprite, and insert all the necessary data so that Construct can obtain the font from the loaded font grid.

    If I want to create multiple text objects with different font properties (e.g. color, spacing, size etc.), I have to load the same sprite multiple times, and I think Construct has to recalculate the font from the loaded sprite each time.

    To avoid this "waste" of memory, I thought of creating a single object, and using events to create a new instance and add a different text each time. In this way I could use a single SpriteFont object, but I don't know if this is a good solution since in the various tutorials I've seen, a different text object is used for each text in the game.

    That said, I would like to ask you more experts what is the best method to work with SpriteFonts.

    For example, if I have to create several SpriteFont objects, is it advisable to load font sprites containing only the necessary characters in order to "lighten" to Construct the work necessary to build the font? Or are there no problems in selecting and assigning the usual sprite containing all the characters?

    Do you have advices or indications to give me to use in the best way the SpriteFont?

    Thanks! :)

  • Are you using different fonts, sizes, or just color variations?

  • It would probably be more memory-efficient to use a single sprite font object for everything, but that isn't always practical, either technically or in terms of workflow.

    But if you do want to, assign each object a local variable that acts as a unique identifier ("textID"), like "playerScore" or "currentLevel". Create a single function that is used to change the text objects as needed. Give it a parameter "textID" and then use that to pick which object to change, and set its text/colour/whatever using more parameters as needed.

    That's how I do it, at least. But I often end up needing multiple text objects regardless. As I say it's not always practical to use a single object.

  • Are you using different fonts, sizes, or just color variations?

    The sprite font is the same, but depending on the need I use different sizes and colors.

    Thanks for the advice GeoffB.

  • Draw your SpriteFont in high resolution and in white color. Then you can use the color tint and scale properties to get a range of colors and sizes from the same SpriteFont.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Draw your SpriteFont in high resolution and in white color. Then you can use the color tint and scale properties to get a range of colors and sizes from the same SpriteFont.

    Thanks for the suggestion.

    So I really think that the option to manage everything with a single SpriteFont object is the best solution from a performance point of view.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)