Moving sprite doesn't move collideRect?!

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.

An easier way would be to do it at higher level.

playdate.display.setOffset(x, y)
https://sdk.play.date/inside-playdate/#f-display.setOffset

This will reveal the background colour, which you can control.

https://sdk.play.date/inside-playdate/#f-graphics.setBackgroundColor

Ooh, an Oxyd port/clone. Will you be using the accelerometers for movement?

@matt
Thanks for the help. Yes, that worked well.

1 Like

@JaphyRiddle
At the time I only using the D-Pad for movement. A-button and B-button for items. Crank and in-build accelerometers (I mean moving the Playdate itself) is on the very far end at the task list. Main task is to keep the game interesting/funny to play and some kind of physics....