2
\$\begingroup\$

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;
    }
\$\endgroup\$
1
  • \$\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
    Commented Jul 30, 2017 at 19:42

1 Answer 1

2
\$\begingroup\$

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!
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .