Flickering tiles by zooming (solved)

I use for the background sliced images. The problem is when i zoom the screen - sometimes happen the images has flickering borders. I know in as3 / flash there was this problem too, but this can be fixed by turning off by anti aliasing. Solar2D has no anti aliasing anymore, had anyone the same problem? Has anyone a practical solution?

I want to fix it by -> “xPos = xPos - 0.1” in the loop

image


Here is the Code Snipped:
local xPos = 0
local yPos = 0

if (worldMapConfigDataVo ~= nil) then
    for x = 1, worldMapConfigDataVo.tileX do
        ---@type DisplayObject
        local background
        for y = 1, worldMapConfigDataVo.tileY do
            local img, isError = assetModel.loadImage("countrySide/background/" .. stringLower(dataVo.worldMapId) .. "_bg_" .. y .. "_" .. x)
            if (isError == false) then
                background = img
                background.anchorX = 0
                background.anchorY = 0
                background.y = yPos
                background.x = xPos
                backgroundTiles:insert(background)
                yPos = yPos + background.height
            end
        end

        yPos = 0
        if (background ~= nil) then
            xPos = xPos + background.width
        end
    end
else
    logger.error("countrySideView <init> worldMapConfigDataVo is NIL ")
end

Just leaving this here before the thread gets automatically removed.

If you found a solution, which you likely did, then please consider not deleting your post, but instead posting your solution so that others may learn from it if they encounter the same issue.

1 Like

You are right XeduR, i will leave the Topic and describe my solution:

My solution was to round the zoom-factor to maximum decimal place of X.XXXX

`    local scaleCalc = math.round(currentScale*1000)*0.001`

and set the tiles to the scale factor of 1% means in source-code:

     backgroundTiles:insert(background)
     yPos = yPos + background.height
     background:scale(1.01,1.01) <- here 

everything looks normal and the flickering is gone.

2 Likes

yPos = (yPos + background.height) - 0.5

Yes for set the yPos to half up. in the source-code set the background position to bottom

 background.anchorY = 0

In this case it’s not needed. :slight_smile: