How can I do something every second? [LibGDX]

android, java, libgdx

Solution

You can use java.util.Timer.

new Timer().scheduleAtFixedRate(task, after, interval);

task is the method you want to execute, after is the amount of time till the first execution and interval is the time between executions of aforementioned task.

Problem

Lets say I want to make a loop or something that prints out, for example, "Mario" every second. How can I do this? Can't seem to find any good tutorials that teach this anywhere =P

Original source

Related problems