You are previewing AndEngine for Android Game Development Cookbook.
O'Reilly logo
AndEngine for Android Game Development Cookbook

Book Description

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.

  • Step by step detailed instructions and information on a number of AndEngine functions, including illustrations and diagrams for added support and results

  • Learn all about the various aspects of AndEngine with prime and practical examples, useful for bringing your ideas to life

  • Improve the performance of past and future game projects with a collection of useful optimization tips

  • Structure your applications in a manner that provides a smooth flow from splash screen to level selection, to game play

  • In Detail

    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.

    Table of Contents

    1. AndEngine for Android Game Development Cookbook
      1. Table of Contents
      2. AndEngine for Android Game Development Cookbook
      3. Credits
      4. About the Authors
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers and more
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. AndEngine Game Structure
        1. Introduction
        2. Know the life cycle
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. The LayoutGameActivity class
            2. The SimpleBaseGameActivity and SimpleLayoutGameActivity classes
            3. The SimpleAsyncGameActivity class
        3. Choosing our engine type
          1. Getting ready
          2. How to do it…
          3. How it works…
        4. Selecting a resolution policy
          1. How to do it…
          2. How it works…
        5. Creating object factories
          1. Getting ready
          2. How to do it…
          3. How it works…
        6. Creating the game manager
          1. Getting ready
          2. How to do it…
          3. How it works…
        7. Introducing sounds and music
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Music objects
            2. Sound objects
        8. Working with different types of textures
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. BuildableBitmapTextureAtlas
            2. TiledTextureRegion
            3. Compressed textures
          5. See also
        9. Applying texture options
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Texture formats
          5. See also
        10. Using AndEngine font resources
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        11. Creating the resource manager
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        12. Saving and loading game data
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. There's more...
      9. 2. Working with Entities
        1. Introduction
        2. Understanding AndEngine entities
          1. How to do it...
          2. How it works…
          3. There's more...
        3. Applying primitives to a layer
          1. Getting ready…
          2. How to do it…
          3. How it works…
          4. There's more...
          5. See also
        4. Bringing a scene to life with sprites
          1. Getting ready…
          2. How to do it…
          3. How it works…
          4. There's more...
            1. Using OpenGL's dithering capability
          5. See also
        5. Applying text to a layer
          1. Getting ready…
          2. How to do it…
          3. How it works…
          4. There's more...
          5. See also
        6. Using relative rotation
          1. Getting ready…
          2. How to do it…
          3. How it works…
        7. Overriding the onManagedUpdate method
          1. Getting ready…
          2. How to do it…
          3. How it works…
          4. There's more…
        8. Using modifiers and entity modifiers
          1. Getting ready…
          2. How to do it…
          3. How it works…
            1. AndEngine's modifiers
            2. AndEngine's entity modifiers
          4. There's more…
          5. See also
        9. Working with particle systems
          1. Getting ready…
          2. How to do it…
          3. How it works…
            1. Particle emitter selection
            2. Particle initializer selection
            3. Particle modifier selection
          4. See also
      10. 3. Designing Your Menu
        1. Introduction
        2. Adding buttons to the menu
          1. Getting ready…
          2. How to do it…
          3. How it works…
          4. See also
        3. Adding music to the menu
          1. Getting ready…
          2. How to do it…
          3. How it works…
          4. See also
        4. Applying a background
          1. How to do it..
          2. How it works…
          3. There's more...
            1. The EntityBackground class
            2. The SpriteBackground class
            3. The RepeatingSpriteBackground class
          4. See also
        5. Using parallax backgrounds to create perspective
          1. Getting ready…
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        6. Creating our level selection system
          1. Getting ready…
          2. How to do it…
          3. How it works…
            1. Explaining the LevelSelector class
            2. Explaining the LevelTile class
          4. There's more…
          5. See also
        7. Hiding and retrieving layers
          1. Getting ready…
          2. How to do it…
          3. How it works…
          4. There's more...
          5. See also
      11. 4. Working with Cameras
        1. Introduction
        2. Introducing the camera object
          1. How to do it…
          2. How it works…
        3. Limiting the camera area with the bound camera
          1. How to do it...
          2. How it works...
          3. See also
        4. Taking a closer look with zoom cameras
          1. How to do it...
          2. How it works…
          3. There's more…
          4. See also
        5. Creating smooth moves with a smooth camera
          1. How to do it…
          2. How it works…
          3. See also
        6. Pinch-zoom camera functionality
          1. Getting started…
          2. How to do it…
          3. How it works…
          4. See also
        7. Stitching a background together
          1. Getting started...
          2. How to do it…
          3. How it works…
          4. See also
        8. Applying a HUD to the camera
          1. How to do it...
          2. How it works…
        9. Applying a controller to the display
          1. Getting started...
          2. How to do it…
          3. How it works…
        10. Coordinate conversion
          1. How to do it…
          2. How it works…
        11. Creating a split screen game
          1. Getting started…
          2. How to do it…
          3. How it works...
      12. 5. Scene and Layer Management
        1. Introduction
        2. Creating the scene manager
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also...
        3. Setting up the resource manager for scene resources
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also...
        4. Customizing managed scenes and layers
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also...
        5. Setting up an activity to use the scene manager
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also...
      13. 6. Applications of Physics
        1. Introduction to the Box2D physics extension
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        2. Understanding different body types
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Creating category-filtered bodies
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Creating multiple-fixture bodies
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        5. Creating unique bodies by specifying vertices
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        6. Using forces, velocities, and torque
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Applying anti-gravity to a specific body
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        8. Working with joints
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. There's more...
            1. More joint types
              1. The distance joint
              2. The mouse joint
              3. The prismatic joint
              4. The pulley joint
              5. The revolute joint
              6. The weld joint
          5. See also
        9. Creating a rag doll
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        10. Creating a rope
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        11. Working with collisions
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        12. Using preSolve and postSolve
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        13. Creating destructible objects
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        14. Raycasting
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
      14. 7. Working with Update Handlers
        1. Getting started with update handlers
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        2. Attaching an update handler to an entity
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Using update handlers with conditionals
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        4. Handling the removal of an entity from the game
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        5. Adding game timers
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        6. Setting entity properties based on the time passed
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      15. 8. Maximizing Performance
        1. Introduction
        2. Ignoring entity updates
          1. How to do it…
          2. How it works…
          3. See also
        3. Disabling background window rendering
          1. Getting ready...
          2. How to do it...
          3. How it works...
        4. Limiting simultaneous sound streams
          1. How to do it...
          2. How it works…
          3. See also
        5. Creating sprite pools
          1. Getting started…
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        6. Cutting down render time with sprite groups
          1. Getting started…
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
          6. Disabling rendering with entity culling
          7. How to do it…
          8. How it works…
          9. There's more…
          10. See also
      16. 9. AndEngine Extensions Overview
        1. Introduction
        2. Creating live wallpaper
          1. Getting ready
          2. How to do it…
          3. How it works…
          4. See also…
        3. Networking with the multiplayer extension
          1. Getting ready
          2. How to do it...
          3. How it works...
        4. Creating high-resolution graphics with SVG
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. See also…
        5. Color mapping with SVG texture regions
          1. Getting ready
          2. How to do it...
          3. How it works…
          4. There's more…
          5. See also…
      17. 10. Getting More From AndEngine
        1. Loading all textures from a folder
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        2. Using textured meshes
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        3. Applying a sprite-based shadow
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        4. Creating a physics-based moving platform
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
        5. Creating a physics-based rope bridge
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. See also
      18. A. Source Code for MagneTank
        1. Game level classes
          1. ManagedGameScene.java
          2. GameLevel.java
          3. LoadingRunnable.java
          4. Levels.java
          5. BouncingPowerBar.java
          6. MagneTank.java
          7. MagneticCrate.java
          8. MagneticOrb.java
          9. MagneticPhysObject.java
          10. MechRat.java
          11. MetalBeamDynamic.java
          12. MetalBeamStatic.java
          13. ParallaxLayer.java
          14. PhysObject.java
          15. RemainingCratesBar.java
          16. TexturedBezierLandscape.java
          17. TexturedMesh.java
          18. WoodenBeamDynamic.java
        2. Input classes
          1. BoundTouchInput.java
          2. GrowButton.java
          3. GrowToggleButton.java
          4. GrowToggleTextButton.java
        3. Layer classes
          1. LevelPauseLayer.java
          2. LevelWonLayer.java
          3. ManagedLayer.java
          4. OptionsLayer.java
        4. Manager classes
          1. GameManager.java
          2. ResourceManager.java
          3. SceneManager.java
          4. SFXManager.java
        5. Menu classes
          1. LevelSelector.java
          2. LevelSelectorButton.java
          3. MainMenu.java
          4. ManagedMenuScene.java
          5. ManagedSplashScreen.java
          6. SplashScreens.java
          7. Activity and Engine Classes
          8. MagneTankActivity.java
          9. MagneTankSmoothCamera.java
          10. ManagedScene.java
          11. SwitchableFixedStepEngine.java
      19. Index