Book Image

Mastering AndEngine Game Development

By : Maya Posch
Book Image

Mastering AndEngine Game Development

By: Maya Posch

Overview of this book

AndEngine is a popular and easy-to-use game framework, best suited for Android game development. After learning the basics of creating an Android game using AndEngine it's time you move beyond the basics to explore further. For this you need to understand the theory behind many of the technologies AndEngine uses. This book aims to provide all the skills and tools you need to learn more about Android game development using AndEngine. With this book you will get a quick overview of the basics of AndEngine and Android application development. From there, you will learn how to use 3D models in a 2D scene, render a visual representation of a scene's objects, and create interaction between these objects. You will explore frame-based animations and learn to use skeletal animations. As the book progresses, you will be guided through exploring all the relevant aspects of rendering graphics with OpenGL ES, generating audio using OpenSL ES and OpenAL, making the best use of Android's network API, implementing anti-aliasing algorithms, shaders, dynamic lighting and much more. With all this, you will be ready to enhance the look and feel of your game with its user interface, sound effects and background music. After an in-depth study of 2D and 3D worlds and multi-player implementations, you will be a master in AndEngine and Android game development.
Table of Contents (21 chapters)
Mastering AndEngine Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Building a game for Android is easy, thanks to a multitude of game engines and tools that allow you to quickly get started. This is true for AndEngine as well. If you are reading this text, you have probably already tried your hand at, at least, a basic AndEngine game. After getting started like this, the next questions are: how to move from this game to those wonderful games you have seen elsewhere? How to make those cool animations, lighting, shadows, and other amazing effects? And how to get them with AndEngine?

This book takes you through the many advanced topics you may encounter while making the perfect Android-based game. After explaining the theory behind each technology, it proceeds to show you how to implement it in an AndEngine-based application.

What this book covers

Chapter 1, Setting Up the Project, runs through the basics of setting up an AndEngine-based application, as well as shows you how to configure your development environment.

Chapter 2, Replacing 2D Sprites with 3D Models, illustrates how you can use 3D-mesh-based models with AndEngine, adding further tools to your asset development process. This chapter also provides full sample code to demonstrate how to integrate 3D models into AndEngine's rendering process.

Chapter 3, Physics Engine Integration, demonstrates the use of the Box2D physics add-on for AndEngine and discusses 2D versus 3D physics as well as the use of other physics engines.

Chapter 4, Frame-based Animation Sequences, discusses the various ways of implementing animation using frame-based systems. These are demonstrated using AndEngine-based examples.

Chapter 5, Skeletal Animations, looks at the advanced topic of using skeleton-based animation in order to achieve highly refined animation without exceeding resource budgets.

Chapter 6, Creating 3D Effects in 2D, highlights the differences and similarities between 2D and 3D scenes, and tells you how to achieve 3D effects in a 2D scene.

Chapter 7, Static Lighting, shows the various techniques used to add lighting and shadows to a scene without making any dynamic calculations during runtime, as well as the limitations posed by this approach.

Chapter 8, Dynamic Lighting, balances the advantages of using dynamic lighting and shadows against the disadvantages of its runtime requirements.

Chapter 9, User Interfaces, takes a detailed look at the support available for user interfaces as they exist in AndEngine, as well as the use of native Android widgets in an AndEngine application, for example, for text input.

Chapter 10, Shading, Aliasing, and Resolutions, dives into the complex topic of programming GLSL shaders for OpenGL ES 2.0 and better graphics hardware. This chapter also shows you how to add anti-aliasing using this and other methods. Finally, it looks at how to handle the various resolutions of the Android device that the game will eventually run on.

Chapter 11, Adding Sounds and Effects, explores the topic of music and sound effects in a game, looking at native AndEngine APIs as well as the use of OpenSL ES and OpenAL.

Chapter 12, Building Worlds for Our Project, focuses on the broad topic of world-building, including how to construct and load/unload scenes and the management of resources. It also looks at transitioning between different scenes and the concepts of hierarchies and limitations within a scene.

Chapter 13, Networking and Latency, defines the multitude of choices out there for connecting Android devices with each other via a network as well as Bluetooth, and the implications this has on gameplay experiences. This chapter also looks at the MultiPlayer add-on for AndEngine.

Chapter 14, Adding Custom Functionality, finally looks at how you can expand on the lessons learned in this book through a number of techniques to extend AndEngine's functionality without modifying a single line of its code. It also looks at implementing plugin systems in both Java and native code.

What you need for this book

In order to follow along with this book, it is important that you use a computer that is supported by the Android SDK and NDK (running Windows, Mac OS X, or Linux). Both Eclipse with the Android Developer Tool (ADT) plugin and the new Android Studio IDE will work.

Possessing an Android device that supports OpenGL ES 2.0 is also very helpful, although many code samples will likely work on the Android SDK's emulator as well.

Who this book is for

This book is aimed at developers who have gone through all the basic AndEngine tutorials and books and are looking for something more. It's also very suitable for developers with a lot of knowledge of other game engines who are looking to develop games with AndEngine. Knowledge of Java, C++, and Android development is a prerequisite for getting the most out of this book.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

  @Override
  public IVertexBufferObject getVertexBufferObject() {
    return null;
  }

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

  final Display display = getWindowManager().getDefaultDisplay();
  Point point = new Point();
  display.getSize(point);
  int cameraWidth = point.x;
      int cameraHeight = point.y;

Any command-line input or output is written as follows:

git clone https://github.com/assimp/assimp.git

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "An example of this is upon resuming the application, when it may have to let the Actor instances that it manages recreate any hardware buffers."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.