As on the picture below, my level sprites (ltdk map) are aligned to the left of the screen. Might the default behavior. All collideRects are displayed properly.
As wanted to reduce the gap on the right side a little bit for a better looking, I added a +4px to the sprite moveTo (4,0). As expected, the tiles are now centered on the screen, but the collideRects didn't move with the sprites, staying at moveTo (0,0) position.
Here is the code:
for layerName, layer in pairs(ldtk.get_layers(levelName)) do
if layer.tiles then
local tilemap = ldtk.create_tilemap(levelName, layerName)
local layerSprite = gfx.sprite.new()
layerSprite:setTilemap(tilemap)
layerSprite:setCenter(0, 0)
layerSprite:moveTo(4, 0)
layerSprite:setZIndex(layer.zIndex)
layerSprite:add()
for enum, tag in pairs(TAGS) do
local emptyTiles = ldtk.get_empty_tileIDs(levelName, enum, layerName)
if emptyTiles then
local tileSprites = gfx.sprite.addWallSprites(tilemap, emptyTiles)
for i=1,#tileSprites do
local tileSprite = tileSprites[i]
tileSprite:setTag(tag)
end
end
end
end
end
end
Does anyone know what I'm doing wrong here?
Thanks a lot.