You are previewing Learning AndEngine.
O'Reilly logo
Learning AndEngine

Book Description

Design and create Android games with the simple but powerful tool AndEngine

In Detail

AndEngine is a very popular open source OpenGL (open graphics library) Android game engine, used to create mobile games quickly while maintaining the ability to fully customize them.

This book will guide you through the whole development process of creating a mobile game for the Android platform using one of the most popular and easy-to-use game engines available today.

Beginning with the very basics, you will learn how to install AndEngine, gather graphics, add sound and music assets, and design game rules. You will first design an example game and enhance it by adding various features over the course of the book. Each chapter adds more colors, enhances the game, and takes it to the next level. You will also learn how to work with Box2D, a popular 2D physics engine that forms an integral part of some of the most successful mobile games.

By the end of the book, you will be able to create a complete, interactive, and fully featured mobile game for Android and publish it to Google Play.

What You Will Learn

  • Understand the basics of a game engine
  • Install all the required software and download and set up AndEngine along with its physics extension
  • Design basic game rules and gather game assets
  • Create a basic runnable application using AndEngine
  • Display text and graphics in the game
  • Implement basic interactions between the player and the game, making use of the mobile device sensors
  • Simulate real-world physics in-game
  • Finish a polished 2D physics-based
  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. 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.

    Table of Contents

    1. Learning AndEngine
      1. Table of Contents
      2. Learning AndEngine
      3. Credits
      4. About the Author
      5. Acknowledgments
      6. About the Reviewers
      7. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      8. 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. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      9. 1. Setting Up an AndEngine Project
        1. Prerequisites
        2. Downloading and installing the required software
          1. Downloading the Android SDK
          2. Installing the Android SDK
          3. Configuring the Eclipse IDE
        3. Getting the AndEngine libraries
          1. Selecting the correct branch
          2. AndEngine repositories
          3. Downloading the sources
          4. Adding AndEngine to the Eclipse IDE
        4. Creating a new application
          1. Creating a simple Android application
          2. Device configuration
            1. Before Honeycomb
            2. Honeycomb until Ice Cream Sandwich
            3. Jelly Bean and later
          3. Running the application
          4. Adding AndEngine
            1. Adding the required projects
            2. Changing the GameActivity to an AndEngine activity
              1. Understanding the activity lifecycle
              2. The BaseGameActivity class
              3. The onCreateEngineOptions method
              4. The onCreateResources method
              5. The onCreateScene method
              6. The onPopulateScene method
            3. Running the application
        5. Understanding resolution policies
          1. FixedResolutionPolicy
          2. FillResolutionPolicy
          3. RelativeResolutionPolicy
          4. RatioResolutionPolicy
          5. CropResolutionPolicy
        6. Summary
      10. 2. Game Concept and Assets
        1. The game concept
          1. Identifying the basic entities
        2. Getting the assets
          1. Graphics
            1. Graphic formats
            2. The main character
            3. The enemy
            4. Platform and clouds
            5. Putting it all together
          2. Sounds and music
            1. Audio file formats
            2. Sound effects
            3. Music
        3. Scene diagram
        4. Summary
      11. 3. From Assets to Entities
        1. Managing resources
          1. Loading graphics
            1. Bitmap texture format
            2. Texture options
              1. Interpolation
                1. Nearest-neighbor interpolation
                2. Bilinear interpolation
              2. Repeating
              3. Alpha channel settings
            3. Creating the regions
            4. Building the atlas
          2. Texture and alpha bleeding
            1. Texture bleeding
            2. Alpha bleeding
          3. Unloading graphics
          4. Loading sounds and music
          5. Unloading sounds and music
          6. Loading fonts
          7. Unloading fonts
          8. Putting it all together
        2. Entities
          1. Scene
            1. AbstractScene
            2. GameScene
          2. Background
          3. Sprite, tiled sprite, and animated sprite
          4. Main character
            1. Player class
            2. PlayerFactory class
          5. Using the new entity and its factory
          6. Platforms and enemies
          7. Running the code
        3. Summary
      12. 4. HUD and Text Display
        1. Fonts and text
          1. Storing the font on a texture
            1. Storing special characters and international alphabets
              1. Characters from European languages
              2. Korean, Chinese, Japanese, and other similar writing systems
              3. Other writing systems
            2. Workaround for unsupported languages
          2. Other limitations of the font texture
        2. Writing text
        3. HUD
        4. Working with toasts
        5. Localization
        6. Debug output
          1. Logging to LogCat from AndEngine
          2. Logging best practices
        7. Summary
      13. 5. Basic Interactions
        1. A simple animation
          1. An animated sprite
          2. Entity modifiers
        2. User input
          1. Touchscreen
            1. Touch events
            2. The scene touch listener
            3. The entity touch area
            4. Touch area bindings
          2. Accelerometer
            1. Pausing and resuming the accelerometer
        3. Collision detection
          1. Handling collisions
            1. Collision handlers
            2. The collidesWith method
        4. Using correct threads to perform actions
        5. Summary
      14. 6. Physics
        1. The physics engine
          1. Basic terms
          2. Body types
          3. Fixtures
            1. Shapes
            2. Density
            3. Friction
            4. Elasticity
            5. Sensor
          4. The physics world
          5. Forces and impulses
          6. Joints
        2. Adding physics
          1. Adding a physics world
          2. Introducing a collidable entity
          3. Relation between physics bodies and entities
            1. Adding a physics body to the player entity
          4. Adding platforms
          5. Controlling the player character
            1. Changing the gravity vector
            2. Using forces
            3. Using impulses
          6. Setting the velocity directly
        3. Summary
      15. 7. Detecting Collisions and Reacting to Events
        1. Collisions
          1. Detecting collisions
            1. The player-platform collision
            2. The player-enemy collision
              1. The Enemy class and EnemyFactory
              2. Adding enemies to the scene
              3. Updating the contact listener
        2. Game events
          1. The chase camera
          2. Adding and removing platforms and enemies
          3. Detecting the player character's death
          4. Score
          5. Wrapping the world around
          6. Restarting the game after a player dies
          7. Showing a message on game over
            1. Restarting the game on tap
        3. Playing sounds on events
          1. Playing the jump sound
          2. Playing the fall sound when the player's character dies
        4. Summary
      16. 8. Advanced Physics
        1. The Box2D Debug Draw extension
          1. Adding Debug Draw to our AndEngine project
          2. Using Debug Draw in a game
        2. Assembling bodies from fixtures
          1. Creating an empty body
          2. The head fixture
          3. Creating the torso
          4. Creating the legs
          5. Assembling the body
        3. Collision filtering
          1. Category
          2. The category mask
          3. Example of categories and masks
          4. Group index
        4. Joints
          1. The revolute joint
          2. The distance joint
          3. The prismatic joint
          4. The line joint
          5. The weld joint
          6. The friction joint
          7. The pulley joint
          8. The gear joint
          9. The mouse joint
          10. Implementing a revolute joint
        5. Summary
      17. 9. Adding a Menu and Splash Scene
        1. Managing multiple scenes
          1. A splash scene
            1. Updating the resource manager
            2. Creating the scene
          2. The menu scene
          3. The loading scene
          4. The scene manager
          5. Plugging in the SceneManager class
        2. Storing values
          1. Using preferences
          2. Settings
            1. Playing sound according to the settings
          3. High score
        3. Summary
      18. 10. Polishing the Game
        1. What is polishing?
        2. Adding music
          1. Life cycle of the media player
        3. Adding animations using entity modifiers
          1. Chaining modifiers
          2. Modifiers
          3. Ease functions
          4. Using the modifier callback hooks
        4. Particle systems
          1. Creating a flying in the clouds effect
          2. Creating a fire and smoke effect
        5. Parallax background
          1. VerticalParallaxEntity
          2. Creating a parallax background
        6. Shaders
        7. Summary
      19. 11. Testing, Publishing, and What's Next
        1. Creating a production APK
        2. Testing with the production APK
        3. Testing on multiple devices
          1. Using an emulator
        4. Getting in touch with the community
        5. Publishing the game to the Google Play store
          1. Publishing to the beta stage first
          2. Creating the application
          3. Crash reports
            1. Debugging crashes
          4. Publishing to production
        6. Promotion
        7. Next steps
          1. The first week
          2. The first month
        8. Summary
      20. Index