自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(0)
  • 资源 (1)
  • 收藏
  • 关注

空空如也

Pro Android Games

android平台下的游戏开发 Contents at a Glance.................................................................................................. iii About the Author ........................................................................................................ x About the Technical Reviewer ................................................................................... xi Introduction.............................................................................................................. xii ■ Chapter 1: Welcome to Android Gaming.................................................................1 What Skills Do You Need? .................................................................................................1 A Solid Foundation of Android ....................................................................................... 1 A Basic Knowledge of Linux and Shell Scripting ........................................................... 3 What Software Tools Do You Need? ..................................................................................4 Setting Up Your Machine ...................................................................................................4 Getting the Android Source ........................................................................................... 5 Extracting Native Android Libraries ............................................................................... 7 Installing the GNU Toolchain for ARM Processors ......................................................... 8 Writing Custom Compilation Scripts............................................................................ 11 Setting Up Your Development Environment.....................................................................18 You Have Taken the First Step.........................................................................................26 ■ Chapter 2: Compiling Native Code in Android ......................................................27 Your First Native Android App..........................................................................................27 Creating an AVD........................................................................................................... 27 ■ CONTENTS v Creating the Android Project ....................................................................................... 30 Application Architecture .............................................................................................. 32 Compiling and Testing the Shared Library.......................................................................45 Troubleshooting Missing Symbols............................................................................... 48 Testing the Dynamic Library on the Device................................................................. 49 Debugging with strace ................................................................................................ 50 Compiling Statically..................................................................................................... 51 Testing the Native Application.........................................................................................52 What’s Next?....................................................................................................................54 ■ Chapter 3: Building a Java Game from Scratch ...................................................55 Android Gaming vs. Java ME Gaming..............................................................................55 Creating Space Blaster, Your First Java Game ................................................................56 Understanding Game Architecture .............................................................................. 57 Creating the Project..................................................................................................... 59 Creating the Game’s Activity Class.............................................................................. 60 Creating the Game Layout ........................................................................................... 61 Implementing the Game .............................................................................................. 66 Handling Key and Touch Events .................................................................................. 76 Testing on the Emulator...................................................................................................79 What’s Next?....................................................................................................................80 ■ Chapter 4: Java Games Continued: Fun with Polygons ........................................81 About the Chapter Layout ................................................................................................81 Understanding the Caveats of Drawing Polygons in Android...........................................81 Understanding the Caveats of Drawing Rectangles ........................................................83 Creating a Polygon Class for Asteroids............................................................................85 Creating a PolygonSprite Class for Asteroids ..................................................................91 ■ CONTENTS vi Understanding the Game’s Architecture..........................................................................95 Creating the Project .........................................................................................................95 Creating the Game Layout ........................................................................................... 97 Looking at the Resources ............................................................................................ 97 Understanding the Game Life Cycle ............................................................................ 99 Responding to Key Press and Touch Events.............................................................. 110 Testing Asteroids on the Emulator.................................................................................113 What’s Next?..................................................................................................................115 ■ Chapter 5: Hybrid 3D Graphics with OpenGL and JNI .........................................117 The Power of Mobile Devices ........................................................................................118 OpenGL the Java Way....................................................................................................119 Java Main Activity ..................................................................................................... 123 Surface View ............................................................................................................. 124 GL Thread .................................................................................................................. 127 Cube Renderer........................................................................................................... 130 Cube Class................................................................................................................. 134 OpenGL the Native Way .................................................................................................136 Main Activity.............................................................................................................. 138 Native Interface Class................................................................................................ 140 Changes to the Original Sample ................................................................................ 142 Native Cube Renderer................................................................................................ 143 Native Cube ............................................................................................................... 151 Compiling and Running the Sample .......................................................................... 152 Caveats of Porting OpenGL Games to Android...............................................................158 The Veil Has Been Lifted................................................................................................159 ■ CONTENTS vii ■ Chapter 6: 3D Shooters Episode I: Wolfenstein 3D for Android ..........................161 Gathering Your Tools .....................................................................................................161 Downloading the Chapter Source Code..................................................................... 161 Introducing Wolf 3D .......................................................................................................162 Understanding the Game Architecture...........................................................................165 Understanding the Java Classes for Wolf 3D.................................................................167 Creating the Main WolfLauncher Class...................................................................... 168 Creating the Wolf 3D Main Menu............................................................................... 172 Handling Key and Touch Events ................................................................................ 174 Creating the Game Loop ............................................................................................ 175 Making Native Callbacks ........................................................................................... 177 Creating Sound and Music Handlers ......................................................................... 179 Creating Movement Controller Handlers ................................................................... 180 Creating the Movement Controller............................................................................. 182 Sound Classes ........................................................................................................... 190 Native Interface Class................................................................................................ 200 Coding the Native Layer.................................................................................................203 Initializing the Game Loop ......................................................................................... 204 Cascading Messages with C to Java Callbacks......................................................... 206 Compiling the Native Library .........................................................................................213 Writing the Makefile .................................................................................................. 213 Generating JNI Headers............................................................................................. 215 Testing Wolf 3D in the Emulator ....................................................................................215 What’s Next?..................................................................................................................218 ■ Chapter 7: 3D Shooters Episode II: Doom for Android........................................221 The Sky Is the Limit with the Java/C Power Combo ......................................................221 Bringing Doom to a Mobile Device.................................................................................223 ■ CONTENTS viii Game Architecture for Doom.........................................................................................225 Java Main Activity..........................................................................................................227 Creation Handler........................................................................................................ 227 Game Layout.............................................................................................................. 228 Menu and Selection Handlers.................................................................................... 231 Key and Touch Event Handlers.................................................................................. 233 Native Callback Handlers........................................................................................... 234 Navigation Controls ................................................................................................... 238 Audio Classes ................................................................................................................240 Native Interface Class....................................................................................................241 Callback Listener ....................................................................................................... 241 Native Methods.......................................................................................................... 242 C to Java Callbacks ................................................................................................... 243 Native Layer...................................................................................................................245 Native Method Implementations................................................................................ 246 Original Game Changes ............................................................................................. 258 Doom Library (DSO) Compilation ...................................................................................264 Testing Doom for Android in the Emulator.....................................................................266 You Have Done It............................................................................................................269 ■ Appendix: Deployment and Compilation Tips.....................................................271 Signing Your Application................................................................................................271 Creating a Key Store.................................................................................................. 271 Signing the Application.............................................................................................. 272 Using the Android NDK to Compile Libraries from Chapters 6 and 7.............................276 Compiling Wolf 3D with the NDK 1.5 ......................................................................... 277 Compiling the Shared Library .................................................................................... 279 ■ CONTENTS ix Adding Support for OpenGL to the NDK 1.5 ............................................................... 280 Compiling Doom with NDK 1.6 .................................................................................. 282 Final Thoughts ...............................................................................................................284 ■ Index:..................................................................................................................287

2011-10-13

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除