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

Preface

This book will take our readers to a fun-filled ride where they will not just learn about the latest Android N SDK, but also about the other APIs and how they can create highly interactive and interesting games with them. The book will show readers how to create a complete game from scratch, designed for the Android platform. It will start by setting up the Android N SDK and other repositories, and then it will show readers how to customize the development environment. After this, it will show readers how to create game elements, objects, game layouts, game architecture, and game loops. It will create reusable Java code scripts, which will help you in your other game projects. An integral part of game development is to integrate images and graphics seamlessly. As we move ahead, we will show how to efficiently work with moving images, creating sprite animations, particle explosions, in-game entities, Bitmap fonts, and so on. Prototyping can decrease development time significantly; readers will implement prototyping techniques using the libgdx library. Toward the end of the book, readers will get a clear idea of improving game physics and the collision system, to give their game that real-life look.

What this book covers

Chapter 1, Introduction to Android N and Installation of Android SDK, guides the reader through the installation of the necessary software with a step-by-step guide.

Chapter 2, Getting Familiar with Android Studio, works toward making the reader comfortable with the project layout and components needed to get started with developing games with Android Studio.

Chapter 3, Managing Inputs, guides the reader through how to take inputs from the user.

Chapter 4, Creating Sprites and Interactive Objects, teaches how to display images on screen and turn them into interactive objects.

Chapter 5, Adding Animation to Your Game, takes you through how to create animations using sprite sheets.

Chapter 6, Collision Detection and Basic Artificial Intelligence, explores various collision detection methods. It is recommended that the user has a little mathematical understanding of some basic concepts of the coordinates system.

Chapter 7, Adding Boundaries and Using Sprites to Create Explosions, goes through creating boundaries for the game, and then moves on to create an explosion class to create an explosion effect.

Chapter 8, Adding an Explosion and Creating a UI, shows how we will spawn our explosion on screen after creating the explosion class, and then covers on how to create a UI that will display instructions and score the on screen.

Chapter 9, Converting Your Game from 2D to 3D, discusses how to move from making 2D games into 3D games.

Chapter 10, Working Further on 3D Game, introduces the player to further work with 3D objects in the game.

What you need for this book

This book is aimed at those who want to get started with native development with Android. It also gives a ready introduction to the latest version of Android, Android N, and guides the reader through the process of going from developing a simple app to a complex 3D game in a matter of 10 simple chapters.

Who this book is for

This book is for anyone who has a basic knowledge of Java and is interested in making games for Android. No prior knowledge of Android or game development is needed; however, this would be a plus.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning. Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "For instance, you can think of www.google.com as a website's domain name." A block of code is set as follows:

<TextView
    android:text="Hello World!"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/TextView"
    tools:text="helloWorld"
    android:textAppearance="@style/TextAppearance.AppCompat.Headline" />

 

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click on Text, as shown in the following screenshot:"

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/-Learning-Android-Game-Development. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title. To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at [email protected] with a link to the suspected pirated material. We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.