HTML5 sprite animation not playing

Hi,

msg.post("#spriteTile", “play_animation”, { id = hash(“gem_”… self.tiletype) })

i used the line above to change the sprite of my tile sprite, which works perfectly while testing.
When I build on html5 and launch though, the sprites didn’t change, but it’s still playable.

Are there things about html5 builds that I need to take note of?

All platforms should behave the same, so no. I’ll see if I can reproduce this since it sounds like a bug.

It depends on the data-type of self.tiletype in the above example. I assume it is a hash-value, which would in turn invoke tostring. Correctly reverse-hashing values back to their original string-value only works on dev-builds. As soon as you are running a release build, that feature is turned off since it consumes a bit of memory. String-manipulation should always be avoided in game-logic. The above example could be converted to a lookup table, which would be pre-calculated so you could do something like:

msg.post("#spriteTile", "play_animation", {id = anims[self.tiletype]})

You first need to iterate over your tile-types in their string representations and fill the table with

hash("gem_" .. current_tile_type)
2 Likes

I’m adding an issue for some sort of warning when using reverse-hashing.

DEF-1535

1 Like

Thanks, it is working now :smiley: