How do I use sprite fonts with containers?

Get help using Construct 2

Post » Wed Jul 23, 2014 6:35 pm

I'm trying to convert from Texts to Sprite Fonts for performance reasons, and I'm a bit stuck on the differences in how they behave.

I have a card Sprite, which had seven Texts associated with it (name, stats, etc). I had all of these in a container so that I could easily manage them as a unit.

However, when using a Sprite Font, the entire font texture appears to be loaded for every individual object. So if I have seven different Sprite Fonts in the container, that's seven copies of the font texture taking up resources. Which is no good.

The seemingly obvious answer would be to use multiple instances of a single Sprite Font object. But I can't figure out how to make that work properly with containers. If I only have the one Sprite Font object in the container, how will it know which seven instances in particular to select/destroy in association with the rest of the container?

Thanks!
B
8
S
2
Posts: 55
Reputation: 616

Post » Wed Jul 23, 2014 8:33 pm

You could link them manually, using instance UID, and abandon containers. Although the manageability would suffer a bit, you wouldn't have to worry about that duplicate texture problem.
B
75
S
31
G
27
Posts: 1,000
Reputation: 20,735

Post » Wed Jul 23, 2014 8:47 pm

Magistross wrote:You could link them manually, using instance UID, and abandon containers. Although the manageability would suffer a bit, you wouldn't have to worry about that duplicate texture problem.


Thanks for the tip! I thought about trying that, but in this case manageability would suffer quite a lot. There's a whole lot of manipulation of these cards, and the container aspect is used heavily throughout them. The total number of sprites is actually pretty low, so I think I'd rather take a hit on redundant textures than lose container functionality.
B
8
S
2
Posts: 55
Reputation: 616

Post » Mon Jul 28, 2014 12:04 pm

OK, after talking with the powers that be, it turns out that C2 is smart enough to automatically detect redundant textures and only load them once. :)
B
8
S
2
Posts: 55
Reputation: 616


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests