LibGDX Center player on tile half the size..

I refactored my tiled game to use 32x32 tiles instead of 16x16 tiles as I am using the LPC assets for tiles and sprites…The sprite characters are gridded out into 64x64 cells for animation…The player is a bit smaller…

Anyways, i’ve got the grid system set up and i’ve got a square highlighting the cell…But no matter what I do, I can’t get the player to center into the tile…

Here is my simplified render call…


batch.draw(downRegion, playerX - (playerWidth / 2 / 32f), playerY,playerWidth/32f, playerHeight/32f);	

Whereas, playerWidth and playerHeight = 64;

Here is what I get…

I don’t that really explained my problem…I know how to center it in the tile…I think the problem is my movement system is flawed.

Do you use a free movement or a tile based movement system?


batch.draw(downRegion, playerX, playerY, playerWidth/32f, playerHeight/32f);   

Try doing that, you haven’t offsetted the y coordinate, so appears to be centered, try doing that for the x coordinate too. If that doesn’t work you’ll have to show more of your code.

I use free movement. I think there is a better way to do it. Right now it basically adds player speed to x or y depending on key pressed. Then to get the tile x,y, of course I just divide by tilesize. I figured out why it wasn’t centering but I’m still trying to improve my movement.

I appreciate the attempt pocket but all that would do is draw the sprite without centering it or doing anything to it at all.