I'm trying to make smooth following camera using this algorithm:

camera.position.add((pos.x - camera.position.x) * 1.2f * deltaTime, (pos.y - camera.position.y) * 1.2f * deltaTime, 0);

It works fine(camera movements are smooth), but when I move the player appears this artifacts: Before the movement

After the movement

Player move() function:

moveX(SPEED  * deltaTime);


protected void moveX (float amount) {
        float newX = pos.x + amount;
        if (!map.doesRectCollideWithMap(newX, pos.y, getWidth(), getHeight()))
            pos.x = newX;
  • \$\begingroup\$ I had the same issue some time ago and it turned out to be caused by texture bleeding (read up on it here). \$\endgroup\$
    – Charanor
    Jul 30 '17 at 19:42

I found the solution.

  1. Set texture filtering of TiledMap to Nearest.
  2. Add 2px padding to your tileset.
  3. Draw yor sprites 1px broeder each direction.
  4. Profit!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.