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

Chapter 7. Adding Boundaries and Using Sprites to Create Explosions

In our preceding chapter, we covered the part where we successfully detected collisions. Now that we have understood how to deal with collisions, we can play around with our knowledge and add some cool stuff to our game. This chapter will be pretty concise, and if you have understood the concept of collision detection properly, then this will be a breeze for you. Here's what we will do in this chapter:

  • Add a ground for our player as a boundary
  • Detect a collision between our player and rocks
  • Spawn an explosion sprite on the point where a collision takes place

Observe that from the preceding tasks, we have already accomplished our second task, so we have to focus on the first and third tasks. Let's dive into creating a ground for our player because right now our player is simply going down infinitely. We will also add an upper boundary in order to contain our player within the screen, otherwise, our player would go right outside...