Putting dynamic text on cards

Hi guys,

I’m new to GDevelop and I’m hoping to be able to build a roguelike deck building card game.

One of fundamental thing I need to be able to do is to have dynamic texts on the cards, rather than static images - say if the energy cost of a card is reduce, I want it to be displayed.

I started going about it using it using the stickers behaviour to stick the text on the card, then link the Card and Text object together so that I can refresh all card text.

I quickly noticed the issue of z orders - as despite the text are being stuck to the cards, they can float about other cards if I don’t give each of them unique z order values. I think I can do that with just a global or scene variable and an each object loop.

The problem is now I want to take the code out of the scene and put it in a function, and now I’m finding that there’s no way I can stick my text onto a card because it can’t find the behaviour suddenly. I assume this has something to do with scopes, which if there’s no way around, would mean I have to keep the logic within the scene itself (or as external events to make it reusable).

So I’m not sure if I’m going about this in the best way possible, or if there’s really an easier way to achieve what I want.

All the examples I’ve found involved cards that have static images, and I can’t find example where text stays attached to objects - which is understandable to me since the engine seem to focused on platformer / action orientated games.

But I just wondered if I can achieve what I want more efficiently?

This confused me at first too. In order to use behaviours in functions, you need to add them as an extra parameter:

So make sure the Sticker behaviour is attached to your object, then add the object and the Sticker behaviour as two separate parameters in your function.

Oh wow! Thank you for this!

I’ll give it a try but that’s definitely not intuitive for sure!