About the Author |
|
xvii | |
About the Technical Reviewer |
|
xix | |
Acknowledgments |
|
xxi | |
Introduction |
|
xxiii | |
|
Chapter 1 Getting Started |
|
|
1 | (10) |
|
|
1 | (1) |
|
|
1 | (1) |
|
|
2 | (1) |
|
|
3 | (3) |
|
How OpenGL ES Works with Android |
|
|
3 | (3) |
|
|
6 | (1) |
|
|
6 | (2) |
|
|
8 | (1) |
|
|
9 | (2) |
|
Chapter 2 Loading an Image |
|
|
11 | (30) |
|
2.1 Loading an Image Using Core Android Methods |
|
|
12 | (5) |
|
|
12 | (1) |
|
|
12 | (1) |
|
|
12 | (5) |
|
2.2 Loading an Image Using OpenGL ES |
|
|
17 | (23) |
|
|
17 | (1) |
|
|
17 | (1) |
|
|
17 | (22) |
|
|
39 | (1) |
|
|
40 | (1) |
|
|
40 | (1) |
|
2.3 Storing Images for Different Screen Resolutions |
|
|
40 | (1) |
|
|
40 | (1) |
|
|
40 | (1) |
|
|
40 | (1) |
|
Chapter 3 The Splash Screen |
|
|
41 | (10) |
|
3.1 Creating a Splash Screen |
|
|
42 | (4) |
|
|
42 | (1) |
|
|
42 | (1) |
|
|
42 | (4) |
|
3.2 Loading Multiple Images During a Splash Screen |
|
|
46 | (2) |
|
|
46 | (1) |
|
|
46 | (1) |
|
|
46 | (2) |
|
3.3 Fading In to and Out of a Splash Screen |
|
|
48 | (3) |
|
|
48 | (1) |
|
|
48 | (1) |
|
|
48 | (3) |
|
Chapter 4 The Menu Screen |
|
|
51 | (14) |
|
4.1 Create a Two-Button Menu Screen |
|
|
51 | (4) |
|
|
51 | (1) |
|
|
51 | (1) |
|
|
51 | (4) |
|
|
55 | (3) |
|
|
55 | (1) |
|
|
55 | (1) |
|
|
55 | (3) |
|
|
58 | (1) |
|
|
58 | (1) |
|
|
58 | (1) |
|
|
58 | (1) |
|
4.4 Exit a Game Thread Cleanly |
|
|
59 | (2) |
|
|
59 | (1) |
|
|
59 | (1) |
|
|
59 | (2) |
|
4.5 Swap Menu Button Images |
|
|
61 | (2) |
|
|
61 | (1) |
|
|
61 | (1) |
|
|
61 | (2) |
|
4.6 Lock the Screen Orientation |
|
|
63 | (2) |
|
|
63 | (1) |
|
|
64 | (1) |
|
|
64 | (1) |
|
Chapter 5 Reading Player Input |
|
|
65 | (14) |
|
5.1 Detect a Screen Touch |
|
|
65 | (1) |
|
|
65 | (1) |
|
|
65 | (1) |
|
|
65 | (1) |
|
5.2 Detect a Screen Multi-touch |
|
|
66 | (1) |
|
|
66 | (1) |
|
|
66 | (1) |
|
|
66 | (1) |
|
5.3 Divide the Screen into Touch Zones |
|
|
67 | (3) |
|
|
67 | (1) |
|
|
67 | (1) |
|
|
67 | (3) |
|
5.4 Detect a Screen Swipe |
|
|
70 | (4) |
|
|
70 | (1) |
|
|
70 | (1) |
|
|
70 | (4) |
|
5.5 Use the Device Accelerometer |
|
|
74 | (5) |
|
|
74 | (1) |
|
|
75 | (1) |
|
|
75 | (4) |
|
Chapter 6 Loading a SpriteSheet |
|
|
79 | (14) |
|
|
79 | (2) |
|
|
79 | (1) |
|
|
79 | (1) |
|
|
79 | (2) |
|
6.2 Access Images in the Sprite Sheet |
|
|
81 | (3) |
|
|
81 | (1) |
|
|
81 | (1) |
|
|
81 | (3) |
|
6.3 Change Sprite Sheet Frames |
|
|
84 | (3) |
|
|
84 | (1) |
|
|
84 | (1) |
|
|
84 | (3) |
|
6.4 Animate Images from a Sprite Sheet |
|
|
87 | (6) |
|
|
87 | (1) |
|
|
87 | (1) |
|
|
87 | (6) |
|
Chapter 7 Scrolling a Background |
|
|
93 | (12) |
|
7.1 Load the Background Image |
|
|
93 | (7) |
|
|
93 | (1) |
|
|
93 | (1) |
|
|
93 | (7) |
|
7.2 Scroll the Background Horizontally |
|
|
100 | (3) |
|
|
100 | (1) |
|
|
100 | (1) |
|
|
101 | (2) |
|
7.3 Scroll the Background Vertically |
|
|
103 | (2) |
|
|
103 | (1) |
|
|
104 | (1) |
|
|
104 | (1) |
|
Chapter 8 Scrolling Multiple Backgrounds |
|
|
105 | (12) |
|
8.1 Load Two Background Images |
|
|
105 | (7) |
|
|
105 | (1) |
|
|
105 | (1) |
|
|
105 | (7) |
|
8.2 Scroll Two Background Images |
|
|
112 | (3) |
|
|
112 | (1) |
|
|
112 | (1) |
|
|
112 | (3) |
|
8.3 Scroll Two Background Images at Different Speeds |
|
|
115 | (2) |
|
|
115 | (1) |
|
|
115 | (1) |
|
|
115 | (2) |
|
Chapter 9 Syncing the Background to Character Movement |
|
|
117 | (10) |
|
9.1 Scroll the Background in Two Directions |
|
|
117 | (5) |
|
|
117 | (1) |
|
|
117 | (1) |
|
|
117 | (5) |
|
9.2 Move the Background in Response to User Input |
|
|
122 | (5) |
|
|
122 | (1) |
|
|
122 | (1) |
|
|
122 | (5) |
|
Chapter 10 Building a Level Using Tiles |
|
|
127 | (14) |
|
10.1 Load Tiles from a Sprite Sheet |
|
|
127 | (8) |
|
|
127 | (1) |
|
|
127 | (1) |
|
|
127 | (8) |
|
10.2 Create a Level from Tiles |
|
|
135 | (6) |
|
|
135 | (1) |
|
|
135 | (1) |
|
|
135 | (6) |
|
Chapter 11 Moving a Character |
|
|
141 | (12) |
|
11.1 Move a Character in Four Directions |
|
|
141 | (5) |
|
|
141 | (1) |
|
|
141 | (1) |
|
|
141 | (5) |
|
11.2 Move a Character at Different Speeds |
|
|
146 | (2) |
|
|
146 | (1) |
|
|
146 | (1) |
|
|
146 | (2) |
|
11.3 Animate a Character When It Moves |
|
|
148 | (5) |
|
|
148 | (1) |
|
|
148 | (1) |
|
|
149 | (4) |
|
Chapter 12 Moving an Enemy |
|
|
153 | (14) |
|
12.1 Load Enemies to Predetermined Locations |
|
|
153 | (5) |
|
|
153 | (1) |
|
|
153 | (1) |
|
|
153 | (5) |
|
12.2 Load Enemies to Random Locations |
|
|
158 | (5) |
|
|
158 | (1) |
|
|
158 | (1) |
|
|
159 | (4) |
|
12.3 Move Enemies Along a Path |
|
|
163 | (4) |
|
|
163 | (1) |
|
|
163 | (1) |
|
|
163 | (4) |
|
Chapter 13 Moving a Character with Obstacles |
|
|
167 | (8) |
|
13.1 Jump Between Platforms |
|
|
167 | (5) |
|
|
167 | (1) |
|
|
167 | (1) |
|
|
168 | (4) |
|
|
172 | (3) |
|
|
172 | (1) |
|
|
172 | (1) |
|
|
172 | (3) |
|
Chapter 14 Firing Weapons |
|
|
175 | (16) |
|
14.1 Wire a "Fire" Button |
|
|
175 | (4) |
|
|
175 | (1) |
|
|
176 | (1) |
|
|
176 | (3) |
|
|
179 | (8) |
|
|
179 | (1) |
|
|
179 | (1) |
|
|
179 | (8) |
|
14.3 Animate a Thrown Weapon |
|
|
187 | (4) |
|
|
187 | (1) |
|
|
187 | (1) |
|
|
187 | (2) |
|
|
189 | (2) |
|
Chapter 15 Collision Detection |
|
|
191 | (14) |
|
|
191 | (2) |
|
|
191 | (1) |
|
|
191 | (1) |
|
|
191 | (2) |
|
15.2 Detect Collisions Between Multiple Moving Objects |
|
|
193 | (8) |
|
|
193 | (1) |
|
|
193 | (1) |
|
|
193 | (8) |
|
15.3 Change Object Trajectory |
|
|
201 | (1) |
|
|
201 | (1) |
|
|
201 | (1) |
|
|
201 | (1) |
|
15.4 Damage Objects upon Collision and Remove Destroyed Objects |
|
|
202 | (3) |
|
|
202 | (1) |
|
|
203 | (1) |
|
|
203 | (2) |
|
|
205 | (12) |
|
16.1 Assign Point Values to Objects |
|
|
205 | (4) |
|
|
205 | (1) |
|
|
205 | (1) |
|
|
205 | (4) |
|
16.2 Add and Track the Score |
|
|
209 | (2) |
|
|
209 | (1) |
|
|
209 | (1) |
|
|
210 | (1) |
|
16.3 Write the Score to the Screen |
|
|
211 | (6) |
|
|
211 | (1) |
|
|
211 | (1) |
|
|
211 | (6) |
|
|
217 | (6) |
|
17.1 Track Time Within the Game |
|
|
217 | (2) |
|
|
217 | (1) |
|
|
217 | (1) |
|
|
217 | (2) |
|
17.2 Stop the Action When the Time Expires |
|
|
219 | (1) |
|
|
219 | (1) |
|
|
219 | (1) |
|
|
220 | (1) |
|
17.3 Stop the Timer When a Task Completes |
|
|
220 | (3) |
|
|
220 | (1) |
|
|
220 | (1) |
|
|
220 | (3) |
Index |
|
223 | |