Change Image Dynamically

So I want to change the image of a sprite, which should seem pretty easy, except I want to be able to have the source of the image come from an array (which is preloaded with the needed image names). (I have my reasons for needing it to be this way.)

It doesn’t seem like this is possible with the regular GDevelop options, is there a way to do this with Javascript or something?? I’ve been trying everything, but haven’t gotten anything to work yet. If anyone can help me find a way, I’d be super grateful!

1 Like

I think I managed to do this before but it was a real pain. From what I remember the string needs to match the exact path string that you’ll find in the resources manager. Such as “assets/player.png”. Also the asset, I’m pretty sure, needs to be loaded in memory first so you’ll probably have to check “always loaded in memory” in the asset manager. Hope I’m remembering right lol

Thanks!! Do you remember if you used Javascript for doing that? Or were you able to do it naturally in GDevelop?

No, I only used events. I may have only done this with playing audio however… I’ll try to find it in any case

Thank you so much! I’d love to see an example, either way!