Book Image

Learning Android Game Development

By : Malankar
Book Image

Learning Android Game Development

By: 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 (11 chapters)
4
Creating Sprites and Interactive Objects

Creating explosions


We're almost done with our game here, and only the following two parts are remaining:

  • Adding particle effects of an explosion
  • Displaying our score on the screen

We will divide this part into two sections wherein we will finish half of our explosions in this chapter, and the further half will be completed along with the UI of our game that will then conclude this game. So, let's get started with this now. For our explosion, we will be needing a sprite sheet. We will use the following sprite sheet for our game:

Our explosion sprite sheet

We will create a new class named ExplosionEffect.java. Note here that we will not be extending this file to our GameObj file since we don't need any of the collision components of this image. We will simply spawn it on the screen and make it stay at the same place. So, open up your ExplosionEffect.java file and let's define our variables first:

private int xc;
private int yc;
private int height;
private int width;
private int row;
private AnimationClass...