Screen s in libgdx are updated once per an interval called a tick. For each tick, the render method is called, and only once it’s complete can another tick occur . This means all your game’s logic other than (de)initialization should be called from render , and - ideally - run in the same thread.

Due to machine-specific issues or issues with the game logic itself , the length of time each tick can take is not constant - this is why the delta parameter is provided, giving the millisecond amount between current an previous ticks.

As you have probably figured out by now, we’re going to need to tap into the tick mechanism to get started. So, let’s end this installment by printing up subsequent ticks. Here’s how our MainScreen will look now:

class MainScreen extends ScreenAdapter { lazy val camera = new OrthographicCamera() val batch: SpriteBatch = new SpriteBatch() var tick = 1L lazy val font = { val f = new BitmapFont() f.getData.setScale(2f) f } override def render(delta: Float) = { tick += 1 (1) //print tick Gdx.gl.glClearColor(0, 0, 0.5f, 1) Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT) camera.update() batch.setProjectionMatrix(camera.combined) batch.begin() font.draw(batch, s"Tick: $tick", 0, font.getCapHeight) (2) batch.end() } override def show() = { camera.setToOrtho(false, 800, 480) } }

1 Setting the tick number…​ 2 …​and printing it out.