Matt
Matt

Reputation: 1704

LibGDX render() method not firing

I have a render method and I can't figure out why it isn't happening. Here's the code I have so far:

public class DevMaze extends Game {

    SpriteBatch batch;
    BitmapFont font;

    public void create() {
        ...
        this.setScreen(new MainMenuScreen(this));
        ...
    }

    public void render() {
        super.render();
    }

    ...
}

The MainMenuScreen gets set and renders just fine, here's the code:

    public class MainMenuScreen implements Screen {

    final DevMaze game;
    OrthographicCamera camera;

    public MainMenuScreen(final DevMaze g) {
        this.game = g;

        camera = new OrthographicCamera();
        camera.setToOrtho(false, 800, 480);
    }

    public void render(float delta) {
        ...
        if (Gdx.input.isTouched()) {
            game.setScreen(new GameScreen(game));    // This line runs
            dispose();
        }
    }

But when I set the screen to my GameScreen, the Constructor runs just fine, but the render method never fires:

public class GameScreen implements Screen {

    final DevMaze game;
    OrthographicCamera camera;
    ...

    public GameScreen(final DevMaze g) {
        this.game = g;

        // Create Camera
        camera = new OrthographicCamera();
        camera.setToOrtho(false, 800, 480);

        // Load assets
        ...

        System.out.println("ONE MORE LINE!");    // This prints
    }

    public void render() {
        System.out.println("MADE IT TO GAME SCREEN");    // This does not prints

        ...
    }

I need to know why the render method is not firing.

I really don't know where to go from here. Every other resource I can find tells me to make sure I have super.render() in my game extending class - which I do. I tried to remove the code I thought would be irrelevant and leave the pertinent stuff, but if there is any other information that you would need to figure out what's going on here just let me know.

This is also one of my first projects with LibGDX, so if this is a stupid question sorry in advance!

Thanks.

Upvotes: 0

Views: 1201

Answers (1)

noone
noone

Reputation: 19796

public void render() needs to be public void render(float deltaTime) in your GameScreen class. I assume that you have another method with the deltaTime in your GameScreen, which gets fired instead, because otherwise it wouldn't compile.

Upvotes: 4

Related Questions