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 now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Learning Android Game Development
Learning Android Game Development

Learning Android Game Development: A Beginner's guide to developing popular Android games

eBook
€15.99 €23.99
Paperback
€29.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Learning Android Game Development

Introduction to Android N and Installation of Android SDK

Welcome to the world of Android and game development. You are about to begin a journey that will set up a foundation for you to get started with converting your wildest imaginations into games. This book will be your stepping stone to creating amazing games. If you are a complete newbie, you will go through a steep yet comfortable learning curve, and, by the end of this book, you will have created your own game.
This book's chapters have been divided into extremely easy-to-understand parts, which require no prior experience in game development. Experience in programming, however, is a must.
This chapter will guide you through an introduction to Android N along with steps for installation of required software. In short, you will be learning the following in this chapter:

  • Short introduction to Android N
  • Introduction to game development with a few examples of games that are doing well
  • Installation of Android Studio
  • Components of Android Studio and setting up for Android N
  • Quick introduction to some basic concepts in Android

Introduction to Android N

It all started way back in 2005 when Google acquired a new company, which would later change the course of mobile computing for good. Yes, you guessed it right! The company that was acquired was the developer of the Android operating system. Since then, Android has seen a lot of developments and has grown significantly in terms of its user base because of the might of Google. At the time of writing this book, Android N is the latest version of this OS. Market share of Android has been growing ever since and is currently at 87.6% of total mobile computing devices. This is huge, and therefore, from a developer perspective, it is extremely important to develop for this platform because most of the mobile base are Android users.

Android N stands for Android Nougat. You must be aware of the naming convention for Android versions. If you are not, they are named in an incremented alphabetical fashion and each version is named after a sweet, barring the exception of the first two versions. Here’s a quick look at the different versions of Android:

  • Alpha
  • Beta
  • Cupcake
  • Donut
  • Eclair
  • Froyo
  • Gingerbread
  • Honeycomb
  • Ice Cream Sandwich
  • Jellybean
  • Kit Kat
  • Lollipop
  • Marshmallow
  • Nougat
You can read more about the history of android from the official source at https://www.android.com/history/.

The world of app development is interesting-but even more interesting than that is, one specific field, that is, game development. Mobile games account for the highest number of downloads on the Google Play Store, and, therefore, this is a most exciting time for game developers since Google has established a massive distribution channel and has made it extremely easy for mobile game developers to publish their games. Gone are the days when you’d have to wait for months or even years to crack a publishing deal with a major publisher. In today's times, you can simply sign up on Google Play Store as a developer and in a matter of hours publish your first game, if it is ready, and get feedback from live users.

The world of Android games has seen massive success stories, such as Angry Birds, Candy Crush, Subway Surfers, and so on. Even games with simple gameplay, such as Flappy Bird, have done extremely well, and it was estimated that at the game’s peak it was earning around $50,000 per day in ad revenues. Isn’t that exciting? You are just one click away from getting your game to a potential audience of billions, and, if your game gets noticed, then you’ll be having the time of your life.

You can make a game as simple as a text-based game or as complex as a third-person shooter. You are only as restricted as your imagination. Plus, all the resources you need are available easily today online. This book will serve you as a ready reference to get started in the world of Android game development and will use the latest version of Android, so you are up-to-date with your knowledge. You don’t necessarily need to have prior experience of developing games for Android platform; however, if you do, then that would be a plus. You do need to have a little bit of Java programming experience, though, to get started. However, rest assured that this book’s language is going to be as easy to understand as possible, and in the whole process of developing your first game for Android, you will have a lot of fun.

So, without further ado, let’s dive right into this exciting journey of developing games for Android using the latest components and tools available at our disposal. I hope you have a great time reading and implementing simultaneously from this book and would highly recommend that you make your own notes while going through this book.

Software requirements

To start our journey into game development for Android, we will need certain software installed on your computer. We will use the latest version of Android Studio, as of this writing, to get started. This chapter will guide you through the installation process.

Before you start your installation, make sure that your computer meets the following system requirements:

  • Windows:
    • Microsoft® Windows® 7/8/10
    • 3 GB RAM minimum, 8 GB RAM recommended; plus 1 GB for the Android Emulator
    • 2 GB of available disk space minimum, 4 GB recommended (500 MB for IDE + 1.5 GB for Android SDK and emulator system image)
    • 1280 x 800 minimum screen resolution
    • For accelerated emulator, 64-bit operating system and Intel® processor with support for Intel® VT-x, Intel® EM64T (Intel® 64), and Execute Disable (XD) Bit functionality
  • Mac:
    • Mac® OS X® 10.10 (Yosemite) or higher, up to 10.12 (macOS Sierra)
    • 3 GB RAM minimum, 8 GB RAM recommended; plus 1 GB for the Android Emulator
    • 2 GB of available disk space minimum, 4 GB recommended (500 MB for IDE + 1.5 GB for Android SDK and emulator system image)
    • 1280 x 800 minimum screen resolution
  • Linux:
    • GNOME or KDE desktop
    • 64-bit distribution capable of running 32-bit applications
    • GNU C Library (glibc) 2.11 or later
    • 3 GB RAM minimum, 8 GB RAM recommended; plus 1 GB for the Android Emulator
    • 2 GB of available disk space minimum, 4 GB recommended (500 MB for IDE + 1.5 GB for Android SDK and emulator system image)
    • 1280 x 800 minimum screen resolution
    • For accelerated emulator, Intel®processor with support for Intel®VT-x, Intel® EM64T (Intel® 64), and Execute Disable (XD) Bit functionality, or AMD processor with support for AMD Virtualization (AMD-V)
Emulator acceleration requires that you install either Intel Hardware Accelerated Execution Manager (Intel HAXM) or Kernel-based Virtual Machine (KVM), which are types of hypervisors. If the needed hypervisor isn't installed, Android Studio typically prompts you to install it. Without acceleration, the emulator takes the machine code from the VM and translates it block-by-block to conform to the architecture of the host computer. This process can be quite slow. However, if the VM and the architecture of the host computer matches (such as x86 on x86), the emulator can skip translating the code and simply run it directly on the actual CPU using a hypervisor. In this case, the emulator can approach the speed of your actual computer.

You can start installing Android Studio from the following URL:

For writing of this book, we have used a Windows 10 system with minimum system requirements. Once you have downloaded Android Studio's .exe file, go through the following steps to finish the installation:

  1. Open the .exe file that you  have just downloaded
  2. Follow the setup wizard and install it using Standard installation

Once you have done this, you will be ready to launch Android Studio with the SDK components needed for Android N; SDK tools version for Android is 25.0.0.

The installation steps are as follows:

Press Next to start with the setup:

Make sure that you have enough space for installation and then proceed by clicking Next:

Once you have read through the terms and agreements, press I Agree to proceed:

Select your desired path for the installation of Android Studio and press Next:

Create a start menu item for quick access and press Install:

Wait until the installation process finishes:

You are now finished with the installation of Android Studio; press Finish to proceed.

Now, you need to configure Android Studio with Android N SDK. The steps to do so, are illustrated as follows:

Since we are installing a fresh copy, select the last option as seen in the screenshot and press OK:

Press Next to proceed:

Select Standard installation for recommended settings:

Press Finish to start downloading the required components.

Once you press Finish, your computer will start downloading the required components for Android N SDK, so ensure that your Internet connection is working and sit back and enjoy a cup of coffee while SDK gets installed on your system:

You have now successfully installed Android Studio and the components needed for Android N.

Once you are done downloading all the components of SDK, you will be ready to start Android Studio and will get the following screen menu:

Congratulations! You are ready to start Android Studio now!

The nuts and bolts of Android

Before you start a new project in Android Studio, there are some basic concepts you must be familiar with. So, let's take a look at a few common terms we will be dealing with in our chapters. 

Package names

The first thing that you will come across is something called a Package Name. It's quite easy to understand actually. A package name is simply like a reverse URL. Think of a package name as your app's domain name-just like a website, only in reverse. For instance, you can think of www.google.com as a website's domain name; in exactly the same way, the naming convention of an Android app is the reverse of a website. So, you can name your app something like com.google.www. There is no strict rule that says that your package name must start from com, but it is the most commonly accepted convention. You can also name your package name randomly using your own set of conventions, such as abc.xyz.lmnmygame.mycompany.mynameand so on. Also, it is extremely important to note that package names must be unique and should not match the package name of any other existing app on the Google Play Store.

It is very important to choose a unique package name since the URL gets indexed by Google and is crucial for your game or app to be noticed on the Google Play Store. So, ensure that you use a unique package name for your game. Also, another interesting fact is that you can predict your app's URL even before it goes live if you have finalized it on your package name. For this reason, you cannot use the same package name of another app since it's already live on Google Play Store. Your app will be live according to the following URL convention:

https://play.google.com/store/apps/details?id=*package_name_here*

So, if your package name is abc.xyz.lmn, then your app's URL will be as follows:

https://play.google.com/store/apps/details?id=abc.xyz.lmn

Layouts

The next concept is Layouts. We will be dealing with Layouts in the next chapter but, just to give you a small introduction, let's provide a few examples. We will make a game, and in a game, we do not need to display the status bar, which means that we need to have a Fullscreen Layout. If you were making an app, then you probably would not mind allowing the status bar to be displayed on top. So, in this case, you can use a Relative Layout or Linear Layout. The really interesting aspect of this book is that, by the end, you will also have a basic idea of how to create a non-gaming app as well. So, it is highly recommended that you grasp the knowledge of the first three chapters properly.

Android Manifest file

Another important concept while making an Android app or a game is the Android Manifest file. To explain this file simply, it contains all the rules or, in more generalized terms, Permissions needed for an app. You must have observed on Google Play Store that, before you download any app, you are prompted with a dialog box that tells you what permissions are needed for the app to run. These permissions are basic rules that are needed to be fed in the Android Manifest file in order to have a transparency to let your user know what information is going to be taken from them. So, for instance, if an app requires access to the Internet, then it is required for the developer to make sure that they include the Internet permission in the manifest file. If the developer does not write this permission in the manifest file, then the app will not be able to access the said functionality, and the same goes for accessing contacts, gallery, camera, and everything else.

These are the three most important things you need to keep in mind before you start developing any Android game or an app.

In the next chapter, we will get started with our first project on Android Studio.

Summary

In this chapter, we have learned some basic information about Android as well as how to install Android Studio, which will help us on our journey to developing our apps. We also configured Android studio with components of Android N; you are now ready to get started with game development in Android.

Now that we have installed Android Studio, we will be learning how to execute/run our first program in the next chapter. Fasten your seatbelts, you are in for a ride!

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Leverage the latest features of Android N to create real-world 2D games
  • Architect a 2D game from scratch and level up your Android game development skill
  • Transition from developing simple 2D games to 3D games using basic Java code

Description

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.

Who is this book for?

If you are a mobile developer who has basic Java programming knowledge, then this book is ideal for you. Previous Android development experience is not needed; however, basic mobile development knowledge is essential.

What you will learn

  • Understand the nuts and bolts of developing highly interactive and interesting games for Android N
  • Link the interface to the code used in games through simple methods
  • Interact with the images on the screen and also learn to animate them
  • Set and save the game state and save high scores, hit points, and so on for your games
  • Get a grasp of various collision techniques and implement the bounding box technique
  • Convert your 2D games to 3D games using Android N
  • Get an understanding of the process of UI creation using Android Studio
Estimated delivery fee Deliver to Czechia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 26, 2017
Length: 238 pages
Edition : 1st
Language : English
ISBN-13 : 9781785880957
Vendor :
Google
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Estimated delivery fee Deliver to Czechia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Publication date : May 26, 2017
Length: 238 pages
Edition : 1st
Language : English
ISBN-13 : 9781785880957
Vendor :
Google
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 103.97
Android Programming for Beginners
€41.99
Learning Android Game Development
€29.99
Mastering Android Game Development with Unity
€31.99
Total 103.97 Stars icon

Table of Contents

10 Chapters
Introduction to Android N and Installation of Android SDK Chevron down icon Chevron up icon
Getting Familiar with Android Studio Chevron down icon Chevron up icon
Managing Inputs Chevron down icon Chevron up icon
Creating Sprites and Interactive Objects Chevron down icon Chevron up icon
Adding Animation to Your Game Chevron down icon Chevron up icon
Collision Detection and Basic Artificial Intelligence Chevron down icon Chevron up icon
Adding Boundaries and Using Sprites to Create Explosions Chevron down icon Chevron up icon
Adding an Explosion and Creating a UI Chevron down icon Chevron up icon
Converting Your Game from 2D to 3D Chevron down icon Chevron up icon
Working Further on 3D Game Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
(2 Ratings)
5 star 0%
4 star 0%
3 star 50%
2 star 0%
1 star 50%
Galymzhan Sh Aug 09, 2017
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
238 pages of obsolete information with no prior explanation, including OpenGL ES 1 in 2017.
Amazon Verified review Amazon
Dillon Jul 01, 2017
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
So far it needs further revision, errors pop up in code that should be explained before the code is presented and the changes the reader is instructed to make should be highlighted/in bold (the changes are not in bold which can be confusing to some readers).
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela