-2

Atm I have a box class that I want to be able to add a new box depending on how much time has elapsed. I have an update function with a timer on it to count how many seconds have passed since the program has started as a double. the problem I have is when I call the loadBox method at (if((int) timer == 2)){loadBox();} it adds 30 boxes to the arraylist during the 2 seconds timer is at 2. How do I make it so when the timer is at 2 seconds it only adds 1 box to the arraylist?

1 Answer 1

0

You need to reset the timer the first time the condition is true.

(if((int) timer == 2)){timer=0;loadBox();}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.