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

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.