ok I'm slowly moving along here.
Like I've said, I figured out the nf(). Now I have the pause button working, but when it's "unpaused" it starts as if it never stopped.
Also when the "reset" button is hit, it does the same thing as if I hit the "pause" button.
What I really want, is the clock to start a 00:00 until a "start" button his hit.
Then, I would like to hit the "stop" button, but without the option to continue, rather just freeze the time.
And finally a "reset" button to bring it all back to 00:00.
Code: int startingTime;
float TextFont;
boolean bOver = false;
boolean locked = false;
boolean paused = false;
boolean cOver = false;
void setup() {
size(400, 400);
PFont font= loadFont("Verdana-12.vlw");
textFont(font);
startingTime = millis();
}
void draw() {
background(255,255,255);
int seconds = (millis() - startingTime) / 1000;
int minutes = seconds / 60;
int hours = minutes/60;
seconds-=minutes * 60;
minutes-=hours * 60;
String sm = nf(minutes, 2); //minutes
String s2 = nf(seconds, 2); //seconds
fill(255);
stroke(0);
rect(150,95,100,50);
fill(0,0,0);
text(( sm) + ":" + (s2),185,125);
fill(255);
// Test if the cursor is over the box
if (mouseX > 150 && mouseX < 250 &&
mouseY > 150 && mouseY < 200) {
bOver = true;
if(!locked) {
}
} else {
bOver = false;
}
if (mouseX > 150 && mouseX < 250 &&
mouseY > 205 && mouseY < 265){
cOver = true;
if(!locked){
}
} else {
cOver = false;
}
// Draw the box
rect(150, 150, 100, 50);
fill(0);
text("Reset",184,180);
fill(255);
rect(150, 205, 100, 50);
fill(0);
text("Pause",184, 235);
}
void mousePressed() {
if(bOver) {
locked = true;
startingTime = millis();
} else {
locked = false;
}
if(cOver) {
paused = !paused;
if(paused)
noLoop();
else
loop();
}
}