How can I do something every second? [LibGDX]

后端 未结 3 610
再見小時候
再見小時候 2020-12-30 11:53

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 a

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 12:29

    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.

提交回复
热议问题