万本电子书0元读

万本电子书0元读

顶部广告

Learning Java by Building Android Games电子书

售       价:¥

4人正在读 | 0人评论 9.8

作       者:John Horton

出  版  社:Packt Publishing

出版时间:2015-01-29

字       数:281.6万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
If you are completely new to either Java, Android, or game programming and are aiming to publish Android games, then this book is for you. This book also acts as a refresher for those who already have experience in Java on another platforms or other object-oriented languages.
目录展开

Learning Java by Building Android Games

Table of Contents

Learning Java by Building Android Games

Credits

About the Author

About the Reviewers

www.PacktPub.com

Support files, eBooks, discount offers, and more

Why subscribe?

Free access for Packt account holders

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Downloading the color images of this book

Errata

Piracy

Questions

1. Why Java, Android, and Games?

Is this book for me?

If you just want to learn pure Java

If Android is your focus

Where this book will take you

Why build games to learn to program?

Why Android and Java?

Android is the fastest evolving and growing OS ever

Android developers have great prospects

Android is open source

Java is here to stay

Java is not just for Android

Java is fast and easy to use

A summary of Java and Android

Setting up our development environment

Installing the JDK

Android Studio

Installing Android Studio

Summary

2. Getting Started with Android

Our first game project

Preparing Android Studio

Building the project

Exploring Android Studio

Using the Android Studio visual designer

Android UI types

TextView

Layout elements

ImageView widgets

ButtonView

Using the sample code

Making our game menu

Structuring our code for Android

Life cycle phases – what we need to know

Life cycle phases – what we need to do

Dividing our game into activities

Our first look at Java

Cleaning up our code

Building and installing our game

Emulators and devices

Creating an emulator

Running the emulator

Running our game on the emulator

Building our game

Installing the setup to a device

Future projects

Self-test questions

Summary

3. Speaking Java – Your First Game

Java syntax

The compiler

Making code clear with comments

Storing data and using it with variables

Types of variables

Reference types

Declaration

Initialization

Changing variables with operators

Expressing yourself in Java

Math game – asking a question

Creating the new game activity

Laying out the game screen UI

Coding a question in Java

Linking our game from the main menu

Decisions in Java

More operators

Decision 1 – If they come over the bridge, shoot them

Decision 2 – Else, do this

Switching to make decisions

Math game – getting and checking the answer

Self-test questions

Summary

4. Discovering Loops and Methods

Looping with loops

While loops

Breaking out of a loop

The continue keyword

Do-while loops

For loops

Random numbers in Java

Methods

The structure of a method

Modifier

Return type

Name of a method

Parameters

Getting things done in the method body

Using methods

A working method

Exploring method overloading

Enhancing our math game

Enhancing the UI

The new Java code

Amending GameActivity

The methods

The setQuestion method

The updateScoreAndLevel method

The isCorrect method

Calling our new methods

Finishing touches

Going full screen and locking orientation

Adding a custom image (instead of the Android icon)

Self-test questions

Summary

5. Gaming and Java Essentials

Java arrays – an array of variables

Arrays are objects

A simple example of an array

Getting dynamic with arrays

Dynamic array example

Entering the nth dimension with arrays

An example of a multidimensional array

Array-out-of-bounds exceptions

Timing with threads

A simple thread timer example with the Handler class

Beeps n buzzes – Android sound

Creating sound FX

Playing sounds in Android

Life after destruction – persistence

An example of persistence

The memory game

Phase 1 – the UI and the basics

Phase 2 – preparing our variables and presenting the pattern

Phase 3 – the player's response

Phase 4 – preserving the high score

Animating our game

UI animation in Android

Phase 5 – animating the UI

Self-test questions

Summary

6. OOP – Using Other People's Hard Work

What is OOP?

Why do it like this?

Our first class and first object

Basic classes

More things we can do with our first class

Encapsulation

Controlling the use of classes with access modifiers

Class access in a nutshell

Controlling the use of variables with access modifiers

Variable access in a nutshell

Methods have access modifiers too

Method access in a nutshell

Accessing private variables with the getter and setter methods

Setting up our objects with constructors

Variables revisited

The stack and the heap

A quick break to throw out the trash

Access, scope, this, static, and constructors demo

A quick summary on stack and heap

Inheritance

An example of inheritance

Polymorphism

Abstract classes

Interfaces

More about OOP and classes

Inner classes

Self-test questions

Summary

7. Retro Squash Game

Drawing with Android Canvas

The Android coordinate system

Animating our pixels

Getting started with Canvas and Paint

Android Canvas demo app

Detecting touches on the screen

Preparing to make the retro squash game

The design of the game

The UI

Physics

The structure of the code

The four implementation phases in detail

Phase 1 – MainActivity and onCreate

Phase 1 code explained

Phase 2 – SquashCourtView part 1

Phase 2 code explained

Phase 3 – SquashCourtView part 2

Phase 3 code explained

Phase 4 – Remaining lifecycle methods

Good object-oriented design

Self-test questions

Summary

8. The Snake Game

Game design

The coordinate system

Keeping track of the snake segments

Detecting collisions

Drawing the snake

The code structure

MainActivity

GameActivity

Tidying up onCreate

Animation, sprite sheets, and the Snake home screen

Animating with sprite sheets

Implementing the Snake home screen

Implementing the Snake game activity

Enhancing the game

Self-test questions

Summary

9. Making Your Game the Next Big Thing

How to publish your app

Marketing your app

Adding leaderboards and achievements

Planning the Snake achievements

Step-by-step leaderboards and achievements

Installing the Google Play Services API on your PC

Configuring the Google Play developer console

Implementing the leaderboard in the Google Play developer console

Implementing the achievements in the Google Play developer console

Setting up the Snake project ready for implementation

Implementing the player's sign-in, achievements, and leaderboard buttons

Implementing the leaderboards in code

Implementing the achievements in code

Uploading the updated Snake game to Google Play

What next?

Getting a programmer's job

Building bigger and better games

Self-test questions

Summary

A. Self-test Questions and Answers

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Index

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部