SCHROEDER / Boyles | AndEngine for Android Game Development Cookbook | E-Book | www.sack.de
E-Book

E-Book, Englisch, 380 Seiten

SCHROEDER / Boyles AndEngine for Android Game Development Cookbook

AndEngine is a simple but powerful 2D game engine that's ideal for developers who want to create mobile games. This cookbook will get you up to speed with the latest features and techniques quickly and practically.
1. Auflage 2025
ISBN: 978-1-84951-899-4
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)

AndEngine is a simple but powerful 2D game engine that's ideal for developers who want to create mobile games. This cookbook will get you up to speed with the latest features and techniques quickly and practically.

E-Book, Englisch, 380 Seiten

ISBN: 978-1-84951-899-4
Verlag: De Gruyter
Format: PDF
Kopierschutz: Adobe DRM (»Systemvoraussetzungen)



AndEngine is a broad 2D game engine which allows game developers, both experienced and inexperienced, to develop games for the Android platform with ease. Don't be fooled by the simplicity, though. As easy as it is to 'Äúpick up and go,'Äù AndEngine includes enough functionality to bring any type of 2D game world to life.The 'AndEngine for Android Game Development Cookbook' contains all of the necessary information and examples in order to build the games as you imagine them. The book's recipes will walk you through the various aspects of game design with AndEngine and provides detailed instructions on how to achieve some of the most desirable effects for your games.The 'AndEngine for Android Game Development Cookbook' begins with detailed information on some of the more useful structuring techniques in game design and general aspects of resource management. Continuing on, the book will begin to discuss AndEngine entities, including sprites, text, meshes, and more. Everything from positioning, to modifiers, and even tips on improving entity functionality with raw OpenGL capabilities. From here on, everything from applying physics to your game, working with multi-touch events and gestures, game optimization, and even an overview of the various AndEngine extensions will be covered.The book has a widerange of recipes, from saving and loading game data, applying parallax backgrounds to create a seemingly 3D world, relying on touch events to zoom the game camera, taking screen-shots of the device's screen, and performance optimization using object pools. If physics-based games are more interesting to you, there's also a list of recipes ranging from controlling the world forces and calculating forces applied to bodies, creating destructible objects, and even creating rag-dolls.Pong styled games were fun 35 years ago, but it is time to take your game to the next level with the AndEngine for Android Game Development Cookbook.

SCHROEDER / Boyles AndEngine for Android Game Development Cookbook jetzt bestellen!

Weitere Infos & Material


Know the life cycle


It is important to understand the order of operations when it comes to the initialization of our games. The basic needs for a game include creating the engine, loading the game's resources, and setting up the initial screen and settings. This is all it takes in order to create the foundation for an AndEngine game. However, if we plan on more diversity within our games, it is wise to get to know the full life cycle included in AndEngine.

Getting ready


Please refer to the class named in the code bundle.

How to do it…


The AndEngine life cycle includes a few methods that we are responsible for defining directly. These methods include creating the object, creating the object, and populating the scene with child entities. These methods are called in the following order:

  1. Define the method:
    @Override public EngineOptions onCreateEngineOptions() { // Define our mCamera object mCamera = new Camera(0, 0, WIDTH, HEIGHT); // Declare & Define our engine options to be applied to our Engine object EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new FillResolutionPolicy(), mCamera); // It is necessary in a lot of applications to define the following // wake lock options in order to disable the device's display // from turning off during gameplay due to inactivity engineOptions.setWakeLockOptions(WakeLockOptions.SCREEN_ON); // Return the engineOptions object, passing it to the engine return engineOptions; }
  2. Define the method:
    @Override public void onCreateResources( OnCreateResourcesCallback pOnCreateResourcesCallback) { /* We should notify the pOnCreateResourcesCallback that we've finished * loading all of the necessary resources in our game AFTER they are loaded. * onCreateResourcesFinished() should be the last method called. */ pOnCreateResourcesCallback.onCreateResourcesFinished(); }
  3. Define the method:
    @Override public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) { // Create the Scene object mScene = new Scene(); // Notify the callback that we're finished creating the scene, returning // mScene to the mEngine object (handled automatically) pOnCreateSceneCallback.onCreateSceneFinished(mScene); }
  4. Define the method:
    @Override public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) { // onPopulateSceneFinished(), similar to the resource and scene callback // methods, should be called once we are finished populating the scene. pOnPopulateSceneCallback.onPopulateSceneFinished(); }

How it works…


The code found in this recipe's class is the foundation for any AndEngine game. We've set up a main activity class which serves as the entry point into our application. The activity contains the four main methods included in AndEngine's activity life cycle that we are responsible for, beginning with creating the options, creating the resources, creating the scene, and populating the scene.

In the first step, we are overriding the Engine's method. Inside this method, our main focus is to instantiate our object as well as our object. These two object's constructors allow us to define the display properties of our application. Additionally, we've disabled the screen from automatically turning off during application inactivity via the method call.

In step two, we continue to override the method, which gives us a specified method for creating and setting up any resources needed within our game. These resources may include textures, sounds and music, and fonts. In this step and the following two, we are required to make a call to the respective method callbacks in order to proceed through the application's life cycle. For the method, we must call , which should be included at the end of the method.

Step three involves instantiating and setting up the object. Setting up the Scene can be as simple as displayed in this recipe, or for more complex projects, it may include setting up touch event listeners, update handlers, and more. Once we've finished setting up the Scene, we must make a call to the method, passing our newly created object to the Engine to be displayed on the device.

The final step to take care of includes defining the method. This method is in place specifically for attaching child entities to the Scene. As with the previous two steps, we must make a call to in order to proceed with the remaining AndEngine life cycle calls.

In the following list, we will cover the life cycle methods in the order they are called from the start up of an activity to the time it is terminated.

The life cycle calls during launch are as follows:

  • : This method is the Android SDK's native application entry point. In AndEngine development, this method simply calls the method in our class then applies the returned options to the game engine.
  • : This is another Android SDK native method. Here, we simply acquire the wake lock settings from our object and proceed to call the method for the engine's object.
  • : This method will either call during the initial startup process of our activity or register a Boolean variable as for resource reloading if the activity had previously been deployed.
  • : This method reloads our game resources if our application is brought back into focus from minimization. This method is not called on the initial execution of an application.
  • : This is in place to handle the order of execution of the next three callbacks in the AndEngine life cycle.
  • : This method allows us to declare and define our application's initial resources needed during the launch of our activity. These resources include, but are not limited to, textures, sounds and music, and fonts.
  • : Here, we handle the initialization of our activity's Scene object. It is possible to attach entities to the Scene within this method, but for the sake of keeping things organized, it's usually best to attach entities within .
  • : In the method of the life cycle we are just about finished setting up the scene, though there are still a few life cycle calls which will be handled automatically by the Engine. This method should be used to define the visual result of the Scene when our application first starts up. Note that the Scene is already created and applied to the Engine at this point. It is possible in some cases to see the entities being attached to the Scene if there is no loading screen or splash screen in place and if there are a large number of entities to attach.
  • : It signals that the sequence has finished, reloadinresources if necessary, otherwise doing nothing. Reloading resources depends on the Boolean variable briefly mentioned in the method five life cycle calls back.
  • : This method is called every time our application's orientation changes from landscape to portrait mode or vice versa.
  • : Here we have the final method call which takes place during an activity's startup cycle. If our activity reaches this point without any problems, the engine's method is called, bringing the game's update thread to life.

The life cycle calls during minimzation/termination are as follows:

  • : The first method call when an activity is minimized or terminated. This is the native android pause method which calls the pause method for the objects and reverts the wake lock settings appled by the game engine.
  • : Next, AndEngine's implementation of which simply calls the method on the Engine, causing all of the Engine's update handlers to halt along with the update thread.
  • : In the method, AndEngine clears all graphical resources contained within objects held by the Engine's manager classes. These managers include the...


SCHROEDER JAYME :

Jayme Schroeder was introduced to computers at a very young age. By 11, he had started creating modifications and level packs for his favorite game. By age 16, he had found his true passion in game development and network programming in C++ and OpenGL. In early 2011, Jayme had received an Android smartphone and immediately fell in love with the development experience. Since then, he has been researching and developing for the Android platform on a daily basis.Boyles Brian :

Brian Broyles is a freelance programmer and 2D/3D graphic designer with over 12 years of experience. Before entering the mobile development industry in 2010 as the lead programmer of IFL Game Studio, he designed advanced artificial intelligence systems and graphical effects for interactive PC applications. In addition to his vast programming and design experience, he is also a commercial pilot, instrument flight instructor, and advanced instrument ground instructor.



Ihre Fragen, Wünsche oder Anmerkungen
Vorname*
Nachname*
Ihre E-Mail-Adresse*
Kundennr.
Ihre Nachricht*
Lediglich mit * gekennzeichnete Felder sind Pflichtfelder.
Wenn Sie die im Kontaktformular eingegebenen Daten durch Klick auf den nachfolgenden Button übersenden, erklären Sie sich damit einverstanden, dass wir Ihr Angaben für die Beantwortung Ihrer Anfrage verwenden. Selbstverständlich werden Ihre Daten vertraulich behandelt und nicht an Dritte weitergegeben. Sie können der Verwendung Ihrer Daten jederzeit widersprechen. Das Datenhandling bei Sack Fachmedien erklären wir Ihnen in unserer Datenschutzerklärung.