Hi guys, part of my game takes place in a tilemap. I want to set off particle effects at certain points. Is there a way to get a specific tile and then set off a particle effect there programatically? Cheers
You need to manually calculate the world position of a tile I’m afraid. We have no API functions to help you with this.
To position a particle fx at the center of a tile I think it would be something like this
x = (tile_width * tile_position.x) - (tile_width / 2) y = (tile_width * tile_position.y) + (tile_width / 2)
If you want to be able to click a tile you can get the cell x by doing (assuming no offset)
function round(num) under = math.floor(num) upper = math.floor(num) + 1 underV = -(under - num) upperV = upper - num if (upperV > underV) then return under else return upper end end cell_x = round(click.x/ tile_width) * tile_width
I can make a working example later
Thanks, that’s super helpful.