Hello.
I created game object with sprite and script with property “img”:
And I want to change sprite from script:
go.set("#img", "default_animation", hash("characters_000" .. self.img))
But, I have error: ‘#img’ does not have any property called ‘default_animation’
How, to change sprite from script?
Thanks
Edit: Looks like I don’t know what I’m talking about 
I think editor scripts refers to this:
I don’t believe it’s something you can do at runtime via Lua.
You play an animation like this:
But I’m not aware of a way to change the default animation.
You need the image in the associated atlas (imgIdInAtlas). You can change the default animation Using:
msg.post("#img", "play_animation", {id = hash("imgIdInAtlas")})
img is the id of the sprite attached to the collision object.
4 Likes