How would it be possible to swap out an atlas at runtime

I don’t mean creating an entirely new atlas, but changing a sprite object to have a different atlas which was pre-made

currently I’m making a fighting game, where each character is designed on a single collection, with unique elements being brought in using require statements. The animation names are directly tied to the states from the state machine, which the state machine in question being imported from said character specific code.
This way the majority of code can stay symmetrical with two entities running of the same code for fairness. The only issue I have is swapping the atlas.

Yes, you can change the atlas. I’m guessing you are using sprite components? In that case the property is called “image”, and you can swap it out using go.set:

go.set("#sprite", "image", some_atlas_path)

You can use script properties to define a bunch of atlases you want to switch between as well:

-- these need to be specified at the top of your script:
go.property("skin_base", resource.atlas())
go.property("skin_xmas", resource.atlas())

function init(self)
    -- it's christmas!
    go.set("/go#sprite", "image", self.skin_xmas)
end
5 Likes

this works, thank you!