[LibGDX] Sprite not being drawn

I’m so confused right now. I’ve looked at many examples of drawing sprites with LibGDX and I’m almost certain that I’m doing it correctly. I debugged my code and it’s meant to be drawing my sprite at (0, 0). Here is my code:

Initialized in show method:


    public Player(int x, int y) {
        if(x >= 0 && y >= 0)
            position = new Vector2(x, y);
        else
            throw new IllegalArgumentException(Integer.toString(x) +" "+ Integer.toString(y));
        
        character = new Texture("character.png");
        sprite = new Sprite(character);
        sprite.setPosition(x, y);
        batch = new SpriteBatch();
    }

To draw it:


    public void draw(OrthographicCamera camera) {
        batch.setProjectionMatrix(camera.combined);
        batch.begin();
        sprite.draw(batch);
        batch.end();
    }

Maybe I’m missing something really obvious? ???

How is Your camera set up ?

This is how my camera is set up:


    public void resize(int width, int height) {
        center.set(width/2, height/2);
        camera.viewportWidth = width;
        camera.viewportHeight = height;
        camera.update();
    }

Updating:


        camPos.set(player.getPos());
        camPos.y += center.y;
        if(camPos.x < center.x)
            camPos.x = center.x;
        if(camPos.x + center.x >= Map.getWidth())
            camPos.x = Map.getWidth() - center.x;
        camera.position.set(camPos,0);  
        camera.update();

It’s rendering the map correctly by the way.

Try drawing it at the center of the camera. 0,0 wouldn’t work, I don’t believe.

What a ******* joke. I was rendering it at (0, 0), while not realising this…

http://img36.imageshack.us/img36/5803/6e0j.png

Someone get me some coffee.

We all have those moments man :wink: Those early stages of the project when the simple things don’t work and you want to bash your head in and just forget you ever even heard of coding… yeah I have those too!