How can I do something every second? [LibGDX](我怎么能每秒都做某事?[LibGDX])
问题描述
假设我想制作一个循环或打印出来的东西,例如每秒打印一次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]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我怎么能每秒都做某事?[LibGDX]


- 转换 ldap 日期 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 获取数字的最后一位 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01