We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Functions and Arrays
Page Index Toggle Pages: 1
Functions and Arrays (Read 244 times)
Functions and Arrays
Nov 26th, 2008, 1:23am
 
Hey,

i have a little problem, basically i have an array which spawns 100 balls and this if statement checks to see if they hit the edge of the window, and if so to reverse there course and to play a sequencer track.

void keepBalls() {
 for (int j=0; j<ballCount; j++){
   if (xpos[j]+wdth[j]/2>=width || xpos[j]<=wdth[j]/2){
     xspeed[j]*=-1;
     sequencer.start();
     }
   }

the problem is the track only plays once as it is not being called from the array. i basically need to call the function every time the if statement is true,

any ideas?


thanks!

Alex
Re: Functions and Arrays
Reply #1 - Nov 27th, 2008, 9:44am
 
I don't know what you mean by 'called from the array', but that piece of code looks ok to me.

maybee your sequencer can only play one sound at a time and therefore it gets started multiple times but you only hear it once?

you are doing exactly what you want: you call the start() method once for each time the expression evaluates to true.
Re: Functions and Arrays
Reply #2 - Nov 27th, 2008, 6:42pm
 
yeh, you are correct, it was a sequencer problem, it's all working now, thanks
Page Index Toggle Pages: 1