From FANG
|
01 packagepackage is used to name the directory or folder a class is in scg.ch06;
02
03 importimport means to make the classes and/or packages available in this program fang2.core.Game;
04
05 /**
06 * Demonstration program showing how to use a CountdownTimer object.
07 */
08 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects CountdownTimerTest
09 extendsextends means to customize or extend the functionality of a class Game {open braces start code blocks and must be matched with a close brace
10 /** the countdown timer */
11 CountdownTimer countdown;
12
13 /**
14 * Setup the countdown timer with 30 seconds on its face and place it
15 * in the middle of the screen.
16 */
17 @Override
18 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup() {open braces start code blocks and must be matched with a close brace
19 countdown =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor CountdownTimer();
20 countdown.setScale(0.5);
21 countdown.setLocation(0.5, 0.5);
22 addSprite(countdown);
23
24 countdown.setTimer(30.0);
25 countdown.startTimer();// will start as soon as game starts
26 }close braces end code blocks and must match an earlier open brace
27
28 /**
29 * Advance the game one frame. All the work here is pushed down into
30 * the countdown timer.
31 */
32 @Override
33 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance(doubledouble is the type for numbers that can contain decimal fractions deltaT) {open braces start code blocks and must be matched with a close brace
34 countdown.advance(deltaT);
35 }close braces end code blocks and must match an earlier open brace
36 }close braces end code blocks and must match an earlier open brace
37
38 //Uploaded on Mon Mar 29 21:38:59 EDT 2010
|
Download/View scg/ch06/CountdownTimerTest.java