Setting Boolean to 'True' after X amount of Seconds?
As the title says, are there any simple solutions to make a boolean true after x amount of seconds? Right now, I have it that when the enter key is clicked the boolean will turn true which is ok, but this is for a simple game and the boolean turning true brings an enemy onto the screen, so it's kinda silly if you can control when the enemy will pop up on the screen (since the boolean turning true is done by hitting 'enter').
Since it only brings on one enemy every time the boolean is true, I"d need for it to be set back to false afterward and then be turned to true after x amount of seconds again. Any ideas are appreciated.
Re: Setting Boolean to 'True' after X amount of Seconds?
Assuming you are using a gui, you can a) Multi-thread the application and use something like Thread.sleep to pause threads or b) Using a Swing Timer. I would recommend option b for ease of use.
a) Lesson: Concurrency (The Java™ Tutorials > Essential Classes)
b) How to Use Swing Timers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)