I'm using tiled in libgdx. I'm doing a top down rpg similar to final fantasy 1, 2, etc.
I use setX(getX() + velocity.x * delta); and setY(getY() + velocity.y * delta); to move the player around the map. how can i make the player move tile by tile. and How will I check what tile is the player in? can someone help me. thankyou.
I found this :
void update()(
// Getting the target tile
if ( rightArrowPressed ) {
targetX = (int)(currentX + 1); // Casting to an int to keep
// the target to next tile
}else if ( leftArrowPressed ){
targetX = (int)(currentX - 1);
}
// Updating the moving entity
if ( currentX < targetX ){
currentX += 0.1f;
}else if ( currentX > targetX ){
currentX -= 0.1f;
}
}
from : libGDX: How to implement a smooth tile / grid based game character movement?
but I can seem to see away to implement it in my game.