Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Learning Android Game Development

You're reading from   Learning Android Game Development A Beginner's guide to developing popular Android games

Arrow left icon
Product type Paperback
Published in May 2017
Publisher Packt
ISBN-13 9781785880957
Length 238 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Malankar Malankar
Author Profile Icon Malankar
Malankar
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Introduction to Android N and Installation of Android SDK FREE CHAPTER 2. Getting Familiar with Android Studio 3. Managing Inputs 4. Creating Sprites and Interactive Objects 5. Adding Animation to Your Game 6. Collision Detection and Basic Artificial Intelligence 7. Adding Boundaries and Using Sprites to Create Explosions 8. Adding an Explosion and Creating a UI 9. Converting Your Game from 2D to 3D 10. Working Further on 3D Game

Adding an explosion to our game


In Chapter 7, Adding Boundaries and Using Sprites to Create Explosions, we have already created our ExplosionEffect.java class file. Now, we are left with just one task: to spawn our explosion on the screen. Now, just for reference, we will take a look at the image we will use for our explosion file:

Explosion.png file sprite sheet

Note that the last frame of our explosion has almost no image in it. This is because we are not going to destroy this object; we are simply going to spawn it and let it play its animation for now.

Let's proceed and get our explosion running on our game screen. Again, here we will break down our process into simple steps.

Creating variables

As you should be aware by now, we will work on our GameView.java file to display our explosion. So, open up your GameView.java file. We will start by creating a few variables, as follows:

private ExplosionEffect explosionEffect;
private long startReset;
private boolean reset;
private boolean started...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images