假设我想制作一个循环或打印出来的东西,例如每秒打印一次Mario".我怎样才能做到这一点?似乎在任何地方都找不到任何好的教程来教这个=P
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
可以使用java.util.Timer.
You can use java.util.Timer.
new Timer().scheduleAtFixedRate(task, after, interval);
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.
这篇关于我怎么能每秒都做某事?[LibGDX]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!