Hi,
I’m very new to processing. Right now I’m trying to create a game for kids. The thing is that I’m trying to create a timer and when it is equal to 0 a song will go off. So thanks to this forum and Youtube I manage to create a code that now plays the music (unfortunately the song goes off right away) and my timer counts down from 10, tho it doesn’t stop at 0. Do you know what I should do?
Klocka
Timer startTimer;
import ddf.minim.*;
AudioPlayer player;
Minim minim;//audio context
void setup()
{
size(600, 600);
background(255);
startTimer = new Timer(10);
minim = new Minim(this);
player = minim.loadFile("old.mp3", 2048);
player.play();
}
void draw()
{
background(200);
startTimer.countDown();
fill(0);
text(startTimer.getTime(),20,20);
}
void stop()
{
player.close();
minim.stop();
super.stop();
}
**Timer**
class Timer
{
float Time;
Timer(float set)
{
Time = set;
}
float getTime()
{
return(Time);
}
void setTimer(float set)
{
Time = set;
}
void countDown()
{
Time -= 1/frameRate;
}
}