Encontre seu próximo livro favorito

Torne'se membro hoje e leia gratuitamente por 30 dias.
Mastering AndEngine Game Development

Mastering AndEngine Game Development

Ler amostra

Mastering AndEngine Game Development

Comprimento:
541 página
3 horas
Lançado em:
Sep 28, 2015
ISBN:
9781783981151
Formato:
Livro

Descrição

This book is aimed at developers who have gone through all the basic AndEngine tutorials and books, and are looking for something more. It's also very useful for developers with knowledge of other game engines who are looking to develop with AndEngine. Knowledge of Java, C++, and Android development are a prerequisite for getting the most out of this book.
Lançado em:
Sep 28, 2015
ISBN:
9781783981151
Formato:
Livro

Sobre o autor


Relacionado a Mastering AndEngine Game Development

Livros relacionados
Artigos relacionados

Amostra do Livro

Mastering AndEngine Game Development - Posch Maya

Table of Contents

Mastering AndEngine Game Development

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

Errata

Piracy

Questions

1. Setting Up the Project

Project requirements

Application basics

Creating the scene

Running Android applications

Debugging

Our goals

Summary

2. Replacing 2D Sprites with 3D Models

Why 3D in a 2D game makes sense

2D and 3D compared

Dealing with the third dimension

Setting up the environment

Importing a model

Building our library

Basic Android OpenGL ES

MainActivity

ModelData

Renderer

Scene

Camera

ShaderProgram

Mesh

Actor

Adding 3D models to AndEngine

MainActivity

Scene3D

ShaderProgram3D

The result

Summary

3. Physics Engine Integration

Integrating physics with AndEngine

Integrating Box2D

MainActivity.java

Actor3D.java

A discussion on 2D physics

Summary

4. Frame-based Animation Sequences

Different frame types

Sprite sheets

Full sequence

AnimationPack

The key frame sequence

Object-based animations

Universal Tween Engine

Summary

5. Skeletal Animations

Bones and joints

Defining bones

Defining joints

Animating

Inverse kinematics

Forward kinematics

Limits (constraints)

Rigging

Skinning

3D skeletal animation

Key frames and interpolation

Applying transformations

Interpolation types

2D skeletal animation

Loading skeletal animations

FBX

Assimp

Spine

Spriter

Morph target animation

Summary

6. Creating 3D Effects in 2D

Perspective

Zero-point perspective

Rotation

AndEngine rotation example

Parallax

Parallax scrolling with AndEngine

Axonometric and oblique projection

AndEngine isometric projection (TMX)

Shadows

Summary

7. Static Lighting

Defining lighting

2D static lighting

3D static lighting

The benefits of static lighting and shadows

Lightmaps

Baking lightmaps

Shadow mapping

Shadow volumes

Lights

Common AndEngine lighting effects

Summary

8. Dynamic Lighting

Making lighting dynamic

Dynamic 2D lighting

Ambient lighting

Edge (rim) lighting

Normal mapping

Dynamic 3D lighting

Lightmaps

Shadow mapping

Shadow volumes

Cheap dynamic shadows

Reflections

Combining static and dynamic lighting

Summary

9. User Interfaces

Menu systems

Submenus

Dynamic text-based menus

The on-screen user interface

Visual matching

Controls

Motion

Touch

Digital control

Analog control

Text input

Summary

10. Shading, Aliasing, and Resolutions

Handling different resolutions

Picking a policy

Obtaining display details

OpenGL ES shaders

Adding anti-aliasing

Summary

11. Adding Sounds and Effects

AndEngine's sound classes

The SoundPool implementation

The SoundManager wrapper

OpenSL ES

Manual OpenSL ES usage

OpenAL

Positional audio

Sound effects

Reverb

Managing audio resources

Summary

12. Building Worlds for Our Project

Scene managers

The implementation

The scene file format

Text-based scene files

Parsing and scene construction

INI-format-based scene files

TMX tile maps

Resource management

Transitions

Scene-manager-based transition

Backgrounds

Hierarchies

Constraints

Summary

13. Networking and Latency

Network types

Using a network

Ensuring a network is available

Latency compensation

Server-side lag

Do nothing

Complete synchronization

Relying on client extrapolation

Hybrid

Multiplayer implementations

Real-time multiplayer

Server-based

Peer-to-peer

Hybrid

AndEngine's multiplayer extension

Sending a message

Bluetooth-based

Summary

14. Adding Custom Functionality

The point of noninvasive additions

Extending classes

Limitations

Using native code

A plugin system

Native plugins

A native plugin system

Loading/unloading libraries

Summary

Index

Mastering AndEngine Game Development


Mastering AndEngine Game Development

Copyright © 2015 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: September 2015

Production reference: 1220915

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78398-114-4

www.packtpub.com

Credits

Author

Maya Posch

Reviewers

Harshit Agarwal

Scott Bechtel

John Pericos

Sergio Viudes Carbonell

Commissioning Editor

Kartikey Pandey

Acquisition Editors

Nadeem Bagban

James Jones

Content Development Editor

Susmita Sabat

Technical Editor

Utkarsha S. Kadam

Copy Editor

Vikrant Phadke

Project Coordinator

Suzanne Coutinho

Proofreader

Safis Editing

Indexer

Tejal Daruwale Soni

Production Coordinator

Aparna Bhagat

Cover Work

Aparna Bhagat

About the Author

Maya Posch is a largely self-taught developer with a profound interest in anything related to technology and science. Having discovered programming at a young age, she proceeded to learn a variety of languages, including C++, PHP, Java, Ada, and VHDL. She has worked on mobile, desktop, and embedded applications and games. Together with a good friend, she started a software and game development company called Nyanko (http://www.nyanko.ws/) in 2006. Maya currently lives in Germany, where she works on games and other projects, and maintains a number of technology- and science-related blogs.

I would like to express my profound thanks to my best friend, Trevor Purdy, who provided feedback and constructive criticism throughout the process. Also, my gratitude to my other friends. They tolerated my prolonged absence during the writing process.

About the Reviewers

Harshit Agarwal, an IIT graduate, is currently working as a software developer and engineer at Amazon. He was born in Jhansi, India, and completed his schooling there. He scored above 90 percent in both his high school and board examinations. He cleared the prestigious IIT JEE exam in 2011 with an all-India rank of 1973. He completed his bachelors in computer science and engineering from IIT (BHU) Varanasi in 2015. Harshit secured the first rank in Hackathon, a 24-hour Android application development event organized under the annual college technical fest Technex-2013. As a reward, he was offered an internship at Amazon India during the sophomore year of his graduation.

He has ample technical experience. Owing to his internships, he has had the experience of working for both an established MNC, Amazon, and a leading and fast-growing start-up, Cube26. He was also a teaching assistant for a computer programming course in his undergraduate days. His hobbies include swimming, coin collection, and bike riding.

I am highly indebted to my parents and my friends for their constant motivation and timely help. Their valuable suggestions inspired me to review this book without much difficulty. I express my sincere gratitude and thanks to all those who assisted me directly and indirectly during the course of the review.

John Pericos is a software engineer and IT consultant with a lot of experience in Java web and mobile application development. He has his own IT consulting practice and gaming label company called Bitoxic (http://www.bitoxic.com/). He has more than 10 years of software development experience and more than 4 years of Android development experience. John obtained his degree in the field of computer science from the Victoria University of Wellington, New Zealand. He continues to maintain and develop Android applications. You can find his latest development at http://www.bitoxic.com/.

Sergio Viudes Carbonell is 32 years old. He is a developer from Elche, Spain. He has loved to play video games since childhood (since the time of the ZX Spectrum). He also composes electronic music as a hobby. Then, he started coding and studied computer engineering at the University of Alicante.

Sergio started working as a software and web developer, but what he always wanted to do was create video games. So, he founded Baviux, and now he designs and develops mobile apps and games.

He has worked on these books AndEngine for Android Game Development Cookbook, Learning AndEngine, Mobile Game Design, Mastering Android Game Development, and JavaScript Security.

I would like to thank the author of this book for writing it. Special thanks go to my wife, Estefanía, who encourages and supports me every day.

www.PacktPub.com

Support files, eBooks, discount offers, and more

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

Fully searchable across every book published by Packt

Copy and paste, print, and bookmark content

On demand and accessible via a web browser

Free access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

Preface

Building a game for Android is easy, thanks to a multitude of game engines and tools that allow you to quickly get started. This is true for AndEngine as well. If you are reading this text, you have probably already tried your hand at, at least, a basic AndEngine game. After getting started like this, the next questions are: how to move from this game to those wonderful games you have seen elsewhere? How to make those cool animations, lighting, shadows, and other amazing effects? And how to get them with AndEngine?

This book takes you through the many advanced topics you may encounter while making the perfect Android-based game. After explaining the theory behind each technology, it proceeds to show you how to implement it in an AndEngine-based application.

What this book covers

Chapter 1, Setting Up the Project, runs through the basics of setting up an AndEngine-based application, as well as shows you how to configure your development environment.

Chapter 2, Replacing 2D Sprites with 3D Models, illustrates how you can use 3D-mesh-based models with AndEngine, adding further tools to your asset development process. This chapter also provides full sample code to demonstrate how to integrate 3D models into AndEngine's rendering process.

Chapter 3, Physics Engine Integration, demonstrates the use of the Box2D physics add-on for AndEngine and discusses 2D versus 3D physics as well as the use of other physics engines.

Chapter 4, Frame-based Animation Sequences, discusses the various ways of implementing animation using frame-based systems. These are demonstrated using AndEngine-based examples.

Chapter 5, Skeletal Animations, looks at the advanced topic of using skeleton-based animation in order to achieve highly refined animation without exceeding resource budgets.

Chapter 6, Creating 3D Effects in 2D, highlights the differences and similarities between 2D and 3D scenes, and tells you how to achieve 3D effects in a 2D scene.

Chapter 7, Static Lighting, shows the various techniques used to add lighting and shadows to a scene without making any dynamic calculations during runtime, as well as the limitations posed by this approach.

Chapter 8, Dynamic Lighting, balances the advantages of using dynamic lighting and shadows against the disadvantages of its runtime requirements.

Chapter 9, User Interfaces, takes a detailed look at the support available for user interfaces as they exist in AndEngine, as well as the use of native Android widgets in an AndEngine application, for example, for text input.

Chapter 10, Shading, Aliasing, and Resolutions, dives into the complex topic of programming GLSL shaders for OpenGL ES 2.0 and better graphics hardware. This chapter also shows you how to add anti-aliasing using this and other methods. Finally, it looks at how to handle the various resolutions of the Android device that the game will eventually run on.

Chapter 11, Adding Sounds and Effects, explores the topic of music and sound effects in a game, looking at native AndEngine APIs as well as the use of OpenSL ES and OpenAL.

Chapter 12, Building Worlds for Our Project, focuses on the broad topic of world-building, including how to construct and load/unload scenes and the management of resources. It also looks at transitioning between different scenes and the concepts of hierarchies and limitations within a scene.

Chapter 13, Networking and Latency, defines the multitude of choices out there for connecting Android devices with each other via a network as well as Bluetooth, and the implications this has on gameplay experiences. This chapter also looks at the MultiPlayer add-on for AndEngine.

Chapter 14, Adding Custom Functionality, finally looks at how you can expand on the lessons learned in this book through a number of techniques to extend AndEngine's functionality without modifying a single line of its code. It also looks at implementing plugin systems in both Java and native code.

What you need for this book

In order to follow along with this book, it is important that you use a computer that is supported by the Android SDK and NDK (running Windows, Mac OS X, or Linux). Both Eclipse with the Android Developer Tool (ADT) plugin and the new Android Studio IDE will work.

Possessing an Android device that supports OpenGL ES 2.0 is also very helpful, although many code samples will likely work on the Android SDK's emulator as well.

Who this book is for

This book is aimed at developers who have gone through all the basic AndEngine tutorials and books and are looking for something more. It's also very suitable for developers with a lot of knowledge of other game engines who are looking to develop games with AndEngine. Knowledge of Java, C++, and Android development is a prerequisite for getting the most out of this book.

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: We can include other contexts through the use of the include directive.

A block of code is set as follows:

  @Override

  public IVertexBufferObject getVertexBufferObject() {

    return null;

  }

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

  final Display display = getWindowManager().getDefaultDisplay();

 

Point point = new Point();

 

 

display.getSize(point);

 

  int cameraWidth =

point.x;

 

      int cameraHeight =

point.y;

Any command-line input or output is written as follows:

git clone https://github.com/assimp/assimp.git

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: An example of this is upon resuming the application, when it may have to let the Actor instances that it manages recreate any hardware buffers.

Note

Warnings or important notes appear in a box like this.

Tip

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 <feedback@packtpub.com>, 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 from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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.

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 <copyright@packtpub.com> 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 <questions@packtpub.com>, and we will do our best to address the problem.

Chapter 1. Setting Up the Project

Before you learn the advanced techniques covered in this book, you first need something to work with—a project that you can use as a foundation to implement every new piece of logic and algorithm. To this end, we will use this first chapter to set up the basis for the AndEngine-based application that we will build throughout the following chapters. We will also cover the basics of Android development, in both Java code and native C/C++, and see how to run and debug the resulting applications.

In this chapter, we will cover these topics:

Setting up a basic AndEngine project

Creating scenes

Running Android applications

Debugging

For this chapter, it is assumed that you have at least basic experience with developing Android applications. Experience with either Eclipse/ADT or Android Studio is useful, as is basic knowledge of coordinate systems and OpenGL.

Project requirements

To quickly set up an AndEngine application, we follow the general procedure of pulling the current AndEngine code from the AndEngine GitHub repository and using it as a library project dependency in our project. We will be using the GLES2-AnchorCenter branch for our project because it's the most current development branch at the time of writing this book. An additional advantage of using the AnchorCenter branch is the main change from the GLES2 branch—it uses the same coordinate system as OpenGL, in the sense that the origin is in the bottom-left part of the screen. This will make our lives easier later on, as it will save us the trouble of having to convert between two different coordinate systems.

Another difference between GLES2 and AnchorCenter is that the former positions new objects by default with the corner as the anchor point, while in the latter's case, the default anchor point is at the center of the object. We can change the anchor point wherever needed, of course, but it's good to be aware of this default behavior when we start positioning objects.

When setting up the new Android project, we target the latest available Android SDK version (4.4.2 at the time of writing this book) and use 2.2 as the minimum SDK version, since this is what GLES2 and the related AnchorCenter branch of AndEngine require. The project we are going to create is just a general, blank Android project without any associated themes or input methods. When presented with the choice to enable any of such options in Eclipse/ADT or another wizard, do not choose any of them. What we need is a blank slate, with only a basic Activity class as the starting point.

During the course of this

Você chegou ao final desta amostra. Inscreva-se para ler mais!
Página 1 de 1

Análises

O que as pessoas pensam sobre Mastering AndEngine Game Development

0
0 avaliações / 0 Análises
O que você acha?
Classificação: 0 de 5 estrelas

Avaliações de leitores