Tilesource/Atlas animation does not work in bundle Android/Windows(SOLVED)

I want to do a simple match3 game and started from the Magic Link Tutorial.
I have a simple 2 frame animation that plays before the tile de-spawns. It works fine when I Build it and Build HTML it, but I tried to bundle it for Android and Windows and the animation does not appear.
My Tilesource is organized like this:
Tile1 - Tile1 Glow - Tile 1 Explosion Frame 1 - Tile 1 Explosion Frame 1
Tile2 - Tile2 Glow - Tile 2 Explosion Frame 1 - Tile 2 Explosion Frame 1

Tile6 - Tile6 Glow - Tile 6 Explosion Frame 1 - Tile 6 Explosion Frame 1
Initial animation: Tile X
Animation when tile is selected: Tile X Glow
De-spawn animation: Tile X Explosion Frame 1 + Tile X Explosion Frame 1
The initial animation does appear. The Glow animation does not appear. The Explosion animation does not appear.
The tiles are created with factory.create(tile with Initial animation)

I have set the png to 16bits, still does not work.
Any idea what I might have done wrong or how to fix this?

Can you isolate this problem into a small project and share it here?


I left a tilesource as input
I also have there BBTile.atlas as input that does not work as well.

In tile.script there’s a go.property like this:

go.property("type", hash("coin"))

And you use it like this to figure out which animation to play:

curr_type = tostring(self.type)
curr_type = string.gsub(curr_type, '%]', '')
curr_type = string.gsub(curr_type, '%[', '')
curr_type = string.gsub(curr_type, "hash: ", '')
curr_type = curr_type .. "Glow"
msg.post("#sprite", "play_animation", { id = hash(curr_type) })

This will not work in release builds because in release builds it is not possible to get the string representation of a hash.

-- in debug this returns something like hash: [YellowTile]
-- but in a release build you'd get something like hash: [1234567890]
curr_type = tostring(self.type)

You should use have a lookup table where you can go from hash to string:

local YELLOW = hash("YellowTile")
local WHITE = hash("WhiteTile")
local TYPES = {
	[YELLOW] = "YellowTile",
	[WHITE] = "WhiteTile",
}

function on_message(self, message_id, message, sender)
    ...
	curr_type = TYPES[self.type]
	curr_type = curr_type .. "Glow"

PS You should add the local keyword when declaring variables to prevent them from being globally accessible:

	local curr_type = TYPES[self.type]
	curr_type = curr_type .. "Glow"
3 Likes

Thank you! It works now :slight_smile:

I was curious if this is a LUA thing or Defold thing? If it’s Defold, is there documented somewhere things to consider when running debug vs release builds?

This is a Defold thing. I’m pretty sure its in a manual somewhere but now I can’t find it :-/