I need two timers to run a game, like move objects, and check the other and vice versa Counting Timer As I have tried the following:
timer countdown timer = new timer (1000, this); Timer game timer = new timer (30, this); Public Zero Init () {this.actionPerformed (this); // Add action listener to content pane} @ Override Public Records ActionPerform (Action Source E.E.) {if (EGS Source) == GameTimeer} {// Control Game]} (E. Gets ource () = = Countdown timer} {/ dellmanate timer}} However, when I try to run the applet, it gives a null pointer exception how do I differentiate each timer from the other Separate and desired on every timer tick Do Ary. Thanks
I assume that you use javax.swing.Timer this.actionPerformed (this); does not look correct, because your applet is not ActionEvent . In addition, you should start a timer in the init () method: Expels the public class gameplay Appel ActionListener Public Zero init () {countdownTimer = New Timer ( 1000, this); GameTimer = New timer (30, this); CountdownTimer.start (); GameTimer.start (); } @ Override Public Records ActionPerfed (Action Given E) {If (E.Gates ource () == GameTime) {// Control Game]} (EASSS) == Countdown timer) {// Delmonat timer}}} Redirect to it.
No comments:
Post a Comment