I'm having problems to centralize my sprite animation can someone please give me a light?
public void render() {
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
stateTime += Gdx.graphics.getDeltaTime();
currentFrame = walkAnimation.getKeyFrame(stateTime, true);
batch.setProjectionMatrix(cam.combined);
batch.begin();
batch.draw(currentFrame, Gdx.graphics.getWidth() / 2 - ((walkSheet.getWidth()/FRAME_COLS) / 2), Gdx.graphics.getHeight() / 2 - ((walkSheet.getHeight()/FRAME_ROWS) / 2), width / 2, height / 4);
My animation is being draw a few pixels to the left.
walkSheet.getWidth()/FRAME_COLS...why not just callcurrentFrame.getWidth()instead? - DannyMoTextureRegions correctly. TheTextureRegionmight be centered on the screen, but the sprite might not be centered within theTextureRegion. - DannyMo