Processing: How do i create an object every “x” time

后端 未结 1 868
心在旅途
心在旅途 2020-12-12 05:26

What I want to do is to create a new planet in my system for example every 10 seconds and that it starts to move and also prints a \"hello\" . At the end I want that the 8 p

相关标签:
1条回答
  • 2020-12-12 06:28

    You can use the modulo % operator along with the frameCount variable inside the draw() function to do something every X frames.

    Here is an example program that draws little circles most frames, but draws a big circle every 60 frames:

    void setup() {
      size(500, 500);
      background(0);
    }
    
    void draw() {
    
      ellipse(mouseX, mouseY, 10, 10);
    
      if (frameCount % 60 == 0) {
        ellipse(mouseX, mouseY, 50, 50);
      }
    }
    
    0 讨论(0)
提交回复
热议问题