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]


基础教程推荐
- 多个组件的复杂布局 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 大摇大摆的枚举 2022-01-01