Book Image

Learning Android Game Development

By : Nikhil Malankar
Book Image

Learning Android Game Development

By: Nikhil Malankar

Overview of this book

In this book, we’ll start with installing Android studio and its components, and setting it up ready for Android N. We teach you how to take inputs from users, create images and interact with them, and work with sprites to create animations. You’ll then explore the various collision detection methods and use sprites to create an explosion. Moving on, you’ll go through the process of UI creation and see how to create buttons as well as display the score and other parameters on screen. By the end of the book, you will have a working example and an understanding of a 2D platform game like Super Mario and know how to convert your 2D games to 3D games.
Table of Contents (17 chapters)
Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
4
Creating Sprites and Interactive Objects

Adding animations to make your game more awesome


To start this chapter, we will need a collection of images, which we call sprites. We saw in the previous chapter how we had used  image_1 and image_2 as examples, but we will expand on them and make this more interesting. We will try and make a proper run cycle of our player character in a sprite sheet. To understand this in a better way, let's take a look at the following image:

Our run cycle animation sprites

In the preceding image, you can observe we have a set of images that are prefixed with the text Run followed by a set of numbers that represent frames. So, basically, we will loop from frame Run_000 to Run_009, which will give us a continuous running effect. However, for the sake of simplicity, we will be merging these frames into one single image and read pixel data from it. Also, to keep it simple, we will only make the run cycle animation to three frames. If you want, you can add more frames for better animation quality. So, we will...