Hello! New Defold user here. I’m wondering if it’s possible to change/swap an atlas of a sprite at runtime?
List item
I tried using:
go.set("#sprite", "image", hash("/game/atlas/skin_002.atlas"))
The path seems to be correct, but the game returns “go.set failed with error code -10”
Then I tried:
go.set("#sprite", "image", "/game/atlas/skin_002.atlas")
which obviously returns “the property ‘image’ of ‘#sprite’ must be a hash”
I’ve seen posts on the forum where users define the atlas as a resource like this
go.property("skin_xmas", resource.atlas())
and then use it :
go.set("/go#sprite", "image", self.skin_xmas)
Second approach seems to be working for me, but I’m not sure if I want to use it for something more complex as it feels a bit hardcoded. Is that approach totally fine, or am I missing something here?