How should resource.atlas([path]) work?

Total n00b here. I’m trying to use an atlas to select images for game object sprite. I tried to study the API and I came up with this line

go.property(“types”, resource.atlas("/main.atlas"))

Now, there’s a main.atlas (actually from a template) in the main folder. But I get a build error

/main/pala.script
Types ‘/main.atlas’ could not be found

Why is it not being found? Also, I’m not sure if this is the best way to pick different sprites. But this was the only example in the docs I found. Is there a direct way to address the images?

go.set("#sprite", “image”, [something])

Thanks for any help

In the main folder, as in your_project/main/main.atlas? You are addressing the root folder, so you have to use

go.property("types", resource.atlas("/main/main.atlas"))

Also, if you just want to pick a sprite, you can put multiple images into the atlas, and use sprite.play_flipbook():

sprite.play_flipbook("#my_sprite", "jumping")
1 Like