I've got a few years experience in Java and Slick2D, and I'm attempting to port a game over to libgdx due to the fact that it is a much better library. However, I'm having a simple issue with moving a sprite on the screen. There must be some paradigm I don't understand with this API. I've distilled my code into the following. It recognizes input and runs it through my entire entity and networking systems both to and from the server, and yet the sprite stays at the same location. Any help would be wonderful.
My create() method:
public void create() {
//Check to see if we are using external server or localhost
ClientNetworkManager.setLocalhostAsHost(Constant.useLocalhost, this);
//Begin application setup
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
camera = new OrthographicCamera(1280,900);
batch = new SpriteBatch();
//Load assets into memory
texture = new Texture(Gdx.files.internal("Sprites/Ash.png"));
//texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
sprite = new Sprite(texture);
sprite.setSize(256,256);
sprite.setPosition(44, 666);
//Begin external network setup
setPlayerPointer(null);
this.connection = new ClientConnectionThread(this);
getClientConnectionThread().setCurrentPing(0);
}
My render() method:
public void render() {
//Render logic
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
if (connection.isActive() && !Constant.performEssentialTasksOnly) {
InputManager.handlePlayerInput(this);
batch.setProjectionMatrix(camera.combined);
camera.update();
batch.begin();
batch.draw(sprite,playerPointer.getCurrentX(),playerPointer.getCurrentY());
System.out.println(playerPointer.getCurrentX());
batch.end();
}
}
The values for the getCurrentX/Y methods are all reporting correctly, so that's not the issue. I feel it must be something obvious.
sprite.setPosition()and then usesprite.draw(batch). Also first docamera.update()and thenbatch.setProjectionMatrix()- noone