FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Running Functions
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Running Functions  (Read 236 times)
cap101


Running Functions
« on: Oct 21st, 2004, 3:02am »

Hello everyone.
 
Can functions only be executed to the main window from setup or loop?
 
I am trying to get a for() statement working(from an object call) to create x number of objects over fps.
 
arielm

WWW
Re: Running Functions
« Reply #1 on: Oct 21st, 2004, 5:05pm »

no need to "execute functions" from outside loop() or setup()
 
instead, try something like:
 
Code:
MyClass obj;
 
void setup()
{
  obj = new MyClass();
}
 
void run()
{
  obj.run();
}
 
class MyClass
{
  int frameCounter = 0;
 
  void run()
  {
    frameCounter++;
 
    if ((frameCounter % 5) == 0)
    {
 foo();
    }
  }
}

in that example, the foo() method will be triggered every 5 frames...
 
hth
 

Ariel Malka | www.chronotext.org
Pages: 1 

« Previous topic | Next topic »