当时间 = x 时如何创造一些事情发生 [英] How to create something happen when time = x

查看:62
本文介绍了当时间 = x 时如何创造一些事情发生的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于正在处理中的计时器的问题.我想在每一秒过去后生成一个正方形.我会使用 for 循环、if 语句等吗?

I have a question about timers in Processing. I want to make a square spawn after every second that passes. Would I use a for loop, an if statement, etc.?

推荐答案

你可以在 if 中使用 millis() 函数或 frameCount 变量 语句.

You could just use the millis() function or the frameCount variable in an if statement.

像这样:

void draw(){
   if(frameCount % 60 == 0){
      //do something
   }
}

更多信息可以在参考中找到.

More info can be found in the reference.

这篇关于当时间 = x 时如何创造一些事情发生的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆