Hello!
I’m making a game and took part of the code from an open source example of a match-3 game on Defold, I need to fill the tilemap cells with elements, in this case marshmallows. How to do it? I can’t do it and everything is moving away. Can I spawn an object exactly in the center of the cell? Or if not, how best to do it. Maybe we should abandon tilemaps?
The size of the tile sprite is 256x256, however, to fit the screen size I reduced the scale of the tilemap collection to 0.23
Here is my code:
local function brick_pos(x, y)
return vmath.vector3(x * 64, y * 64, 0.01)
end
local function populate_level(self)
local x, y, w, h = tilemap.get_bounds("board#board")
print("x: " .. w .. " h: " .. h .. " y: " .. y .. " w: " .. w)
for ix = x, x + w - 1 do
for iy = y, h + y - 1 do
local pos = brick_pos(ix, iy)
local props = {}
local ids = collectionfactory.create("#elemfactory", pos, nil, props)
local brick = ids[hash("/element")]
end
end
end
function init(self)
self.bricks = {}
self.completed = false
populate_level(self)
end
Help me please.