Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
AndEngine for Android Game Development Cookbook
AndEngine for Android Game Development Cookbook

AndEngine for Android Game Development Cookbook: AndEngine is a simple but powerful 2D game engine that's ideal for developers who want to create mobile games. This cookbook will get you up to speed with the latest features and techniques quickly and practically.

Arrow left icon
Profile Icon JAYME SCHROEDER Profile Icon Brian Boyles
Arrow right icon
₹799.99 ₹2919.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (25 Ratings)
eBook Jan 2013 380 pages 1st Edition
eBook
₹799.99 ₹2919.99
Paperback
₹3649.99
Subscription
Free Trial
Renews at ₹800p/m
Arrow left icon
Profile Icon JAYME SCHROEDER Profile Icon Brian Boyles
Arrow right icon
₹799.99 ₹2919.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (25 Ratings)
eBook Jan 2013 380 pages 1st Edition
eBook
₹799.99 ₹2919.99
Paperback
₹3649.99
Subscription
Free Trial
Renews at ₹800p/m
eBook
₹799.99 ₹2919.99
Paperback
₹3649.99
Subscription
Free Trial
Renews at ₹800p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
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
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

AndEngine for Android Game Development Cookbook

Chapter 2. Working with Entities

In this chapter, we're going to start getting into displaying objects on the screen and various ways we can work with these objects. The topics include:

  • Understanding AndEngine entities

  • Applying primitives to a layer

  • Bringing a scene to life with sprites

  • Applying text to a layer

  • Using relative rotation

  • Overriding the onManagedUpdate method

  • Using modifiers and entity modifiers

  • Working with particle systems

Introduction


In this chapter, we're going to start working with all of the wonderful entities included in AndEngine. Entities provide us with a base foundation that every object displayed within our game world will rely on, be it the score text, the background image, the player's character, buttons, and everything else. One way to think of this is that any object in our game which has the ability to be placed, via AndEngine's coordinate system, is an entity at its most basic level. In this chapter, we're going to start working with Entity objects and many of its subtypes in order to allow us to make the most out of them in our own games.

Understanding AndEngine entities


The AndEngine game engine follows the entity-component model. The entity-component design is very common in a lot of game engines today, and for a good reason. It's easy to use, it's modular, and it is extremely useful in the sense that all game objects can be traced back to the single, most basic Entity object. The entity-component model can be thought of as the "entity" portion referring to the most basic level of the game engine's object system. The Entity class handles only the most basic data that our game objects rely on, such as position, rotation, color, attaching and detaching to and from the scene, and more. The "component" portion refers to the modular subtypes of the Entity class, such as the Scene, Sprite, Text, ParticleSystem, Rectangle, Mesh, and every other object which can be placed within our game. The components are meant to handle more specific tasks, while the entity is meant to act as a base foundation that all components will rely on...

Applying primitives to a layer


AndEngine's primitive types include Line, Rectangle, Mesh, and Gradient objects. In this topic, we're going to focus on the Mesh class. Meshes are useful for creating more complex shapes in our games which can have an unlimited amount of uses. In this recipe, we're going to use Mesh objects to build a house as seen in the the following figure:

Getting ready…

Please refer to the class named ApplyingPrimitives in the code bundle.

How to do it…

In order to create a Mesh object, we need to do a little bit more work than what's required for a typical Rectangle or Line object. Working with Mesh objects is useful for a number of reasons. They allow us to strengthen our skills as far as the OpenGL coordinate system goes, we can create oddly-shaped primitives, and we are able to alter individual vertice positions, which can be useful for certain types of animation.

  1. The first step involved in creating Mesh objects is to create our buffer data which is used to specify the...

Bringing a scene to life with sprites


Here, we come to the topic which might be considered to be the most necessary aspect to creating any 2D game. Sprites allow us to display 2D images on our scene which can be used to display buttons, characters/avatars, environments and themes, backgrounds, and any other entity in our game which may require representation by means of an image file. In this recipe, we'll be covering the various aspects of AndEngine's Sprite entities which will give us the information we need to continue to work with Sprite objects later on in more complex situations.

Getting ready…

Before we dive into the inner-workings of how sprites are created, we need to understand how to create and manage AndEngine's BitmapTextureAtlas/BuildableBitmapTextureAtlas objects as well as the ITextureRegion object. For more information, please refer to the recipes, Working with different types of textures and Applying texture options in Chapter 1, AndEngine Game Structure.

Once these recipes...

Applying text to a layer


Text is an important part of game development as it can be used to dynamically display point systems, tutorials, descriptions, and more. AndEngine also allows us to create text styles which suit individual game types better by specifying customized Font objects. In this recipe, we're going to create a Text object, which updates itself with the current system time as well as correct its position every time the length of the string grows or shrinks. This will prepare us for the use of Text objects in cases where we need to display scores, time, and other non-specific dynamic string situations.

Getting ready…

Applying Text objects to our Scene object requires a working knowledge of AndEngine's font resources. Please perform the the recipe, Using AndEngine font resources in Chapter 1, Working with Entities, then proceed with the How to do it... section of this recipe. Refer to the class named ApplyingText in the code bundle for this recipe's activity in code.

How to do...

Using relative rotation


Rotating entities relative to the position of other entities in 2D space is a great function to know. The uses for relative rotation are limitless and always seems to be a "hot topic" for newer mobile game developers. One of the more prominent examples of this technique being used is in tower-defense games, which allows a tower's turret to aim towards the direction that an enemy, non-playable character is walking. In this recipe, we're going to introduce a method of rotating our Entity objects in order to point them in the direction of a given x/y position. The following image displays how we will create an arrow on the scene, which will automatically point to the position of the circle image, wherever it moves to:

Getting ready…

We'll need to include two images for this recipe; one named marble.png at 32 x 32 pixels in dimension and another named arrow.png at 31 pixels wide by 59 pixels high. The marble can be any image. We will simply drag this image around the scene...

Overriding the onManagedUpdate method


Overriding an Entity object's onManagedUpdate() method can be extremely useful in all types of situations. By doing so, we can allow our entities to execute code every time the entity is updated through the update thread, occuring many times per second unless the entity is set to ignore updates. There are so many possibilities including animating our entity, checking for collisions, producing timed events, and much more. Using our Entity objects's onManagedUpdate() method also saves us from having to create and register new timer handlers for time-based events for a single entity.

Getting ready…

This recipe requires basic knowledge of the Entity object in AndEngine. Please read through the entire recipe, Understanding AndEngine entities given in this chapter, then create a new empty AndEngine project with a BaseGameActivity class and refer to the class named OverridingUpdates in the code bundle.

How to do it…

In this recipe, we are creating two Rectangle...

Using modifiers and entity modifiers


AndEngine provides us with what are known as modifiers and entity modifiers. Through the use of these modifiers we can apply neat effects to our entities with great ease. These modifiers apply specific changes to an Entity object over a defined period of time, such as movement, scaling, rotation, and more. On top of that, we can include listeners and ease functions to entity modifiers for full control over how they work, making them some of the most powerful-to-use methods for applying certain types of animation to our Scene object in AndEngine.

Note

Before continuing, we should mention that a modifier and an entity modifier in AndEngine are two different objects. A modifier is meant to be applied directly to an entity, causing modifications to an entity's properties over time, such as scaling, movement, and rotation. An entity modifier on the other hand, is meant to act as a container for any number of modifiers, which handle the order in which a group...

Working with particle systems


Particle systems can provide our games with very attractive effects for many different events in our games, such as explosions, sparks, gore, rain, and much more. In this chapter, we're going to cover AndEngine's ParticleSystem classes which will be used to create customized particle effects that will suit our every need.

Getting ready…

This recipe requires basic knowledge of the Sprite object in AndEngine. Please read through the entire recipes, Working with different types of textures in Chapter 1, AndEngine Game Structure, as well as Understanding AndEngine entities given in this chapter. Next, create a new empty AndEngine project with a BaseGameActivity class and import the code from the WorkingWithParticles class in the code bundle.

How to do it…

In order to begin creating particle effects in AndEngine, we require a bare minimum of three objects. These objects include an ITextureRegion object which will represent the individual particles spawned, a ParticleSystem...

Left arrow icon Right arrow icon

Key benefits

  • Step by step detailed instructions and information on a number of AndEngine functions, including illustrations and diagrams for added support and results
  • Learn all about the various aspects of AndEngine with prime and practical examples, useful for bringing your ideas to life
  • Improve the performance of past and future game projects with a collection of useful optimization tips
  • Structure your applications in a manner that provides a smooth flow from splash screen to level selection, to game play

Description

AndEngine is a broad 2D game engine which allows game developers, both experienced and inexperienced, to develop games for the Android platform with ease. Don't be fooled by the simplicity, though. As easy as it is to “pick up and go,” AndEngine includes enough functionality to bring any type of 2D game world to life.The "AndEngine for Android Game Development Cookbook" contains all of the necessary information and examples in order to build the games as you imagine them. The book's recipes will walk you through the various aspects of game design with AndEngine and provides detailed instructions on how to achieve some of the most desirable effects for your games.The "AndEngine for Android Game Development Cookbook" begins with detailed information on some of the more useful structuring techniques in game design and general aspects of resource management. Continuing on, the book will begin to discuss AndEngine entities, including sprites, text, meshes, and more. Everything from positioning, to modifiers, and even tips on improving entity functionality with raw OpenGL capabilities. From here on, everything from applying physics to your game, working with multi-touch events and gestures, game optimization, and even an overview of the various AndEngine extensions will be covered.The book has a widerange of recipes, from saving and loading game data, applying parallax backgrounds to create a seemingly 3D world, relying on touch events to zoom the game camera, taking screen-shots of the device's screen, and performance optimization using object pools. If physics-based games are more interesting to you, there's also a list of recipes ranging from controlling the world forces and calculating forces applied to bodies, creating destructible objects, and even creating rag-dolls.Pong styled games were fun 35 years ago, but it is time to take your game to the next level with the AndEngine for Android Game Development Cookbook.

Who is this book for?

"AndEngine for Android Game Development Cookbook" is geared toward developers who are interested in working with the most up-to-date version of AndEngine, sporting the brand new GLES 2.0 branch. The book will be helpful for developers who are attempting to break into the mobile game market with plans to release fun and exciting games while eliminating a large portion of the learning curve that is otherwise inevitable when getting into AndEngine development.This book requires a working installation of eclipse and the required libraries, including AndEngine and its various extensions set up prior to working with the recipes.

What you will learn

  • Create your ultimate Android games with ease using recipes that take advantage of AndEngine s powerful framework and extensions
  • Make your games playable across a vast range of devices by implementing multi-touch, performance-optimizations, and accurate, screen-resolution scaling
  • Construct a customizable, front-end framework that simplifies menu and level creation
  • Use the Box2D extension to generate realistic, physics-based gameplay and simulations
  • Take advantage of source code for a full-featured game built with AndEngine
  • Make the most of vector-based graphics with AndEngine s SVG extension
  • Build animated, responsive Live-Wallpapers for Android s home screen using the AndEngine s Live-Wallpaper extension
  • Control every aspect of interaction that players have with your games by managing the Android application lifecycles

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 14, 2013
Length: 380 pages
Edition : 1st
Language : English
ISBN-13 : 9781849518994
Category :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
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
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jan 14, 2013
Length: 380 pages
Edition : 1st
Language : English
ISBN-13 : 9781849518994
Category :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
₹800 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
₹4500 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 ₹400 each
Feature tick icon Exclusive print discounts
₹5000 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 ₹400 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 6,926.98
Learning AndEngine
₹3276.99
AndEngine for Android Game Development Cookbook
₹3649.99
Total 6,926.98 Stars icon

Table of Contents

10 Chapters
AndEngine Game Structure Chevron down icon Chevron up icon
Working with Entities Chevron down icon Chevron up icon
Designing Your Menu Chevron down icon Chevron up icon
Working with Cameras Chevron down icon Chevron up icon
Scene and Layer Management Chevron down icon Chevron up icon
Applications of Physics Chevron down icon Chevron up icon
Working with Update Handlers Chevron down icon Chevron up icon
Maximizing Performance Chevron down icon Chevron up icon
AndEngine Extensions Overview Chevron down icon Chevron up icon
Getting More From AndEngine Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(25 Ratings)
5 star 44%
4 star 28%
3 star 16%
2 star 8%
1 star 4%
Filter icon Filter
Top Reviews

Filter reviews by




Natanael Fonseca Nov 17, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The best book made for AndEngine, its examples worked fine to me specifically physics and shapes concepts, i recommend a lot if you are a beginner or advanced programmer.
Amazon Verified review Amazon
Efrain Astudillo Jan 31, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book "saved the bell" lol. I am doing a android game like a asignature project and there are a little information about it. This book is great
Amazon Verified review Amazon
Ramkys Tech May 26, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is a great book if you are planning to develop an app using AndEngine. It covers lots of topics with examples.
Amazon Verified review Amazon
Maxim Yudin Apr 12, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
a cookbook, but it's not for beginners, it's not step-for-step tutorial book, only advices. Thanks so much to an author.
Amazon Verified review Amazon
J. Preston Jan 23, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
AndEngine is an amazing tool to get you up and going on Android programming. I began toying with AndEngine back in May 2013 as a means to support Android development. It's an approachable way of getting 2D games up and going quickly. There are some really good tutorials and samples out there, but Packt Publishing just released this nice book - AndEngine for Android Game Development Cookbook - that will support you if you're planning on exploring AndEngine. I've read other Packt texts, and they're VERY helpful in getting to the code/content you need without a lot of wasted filler. I've even used their Unity3D text for a few years in teaching a course on Unity3D.This cookbook approach is broken up into very specific topics (starting with the lifecycle of an AndEngine app through complex topics like physics interactions). Each topic begins with pre-requisite knowledge and an overview, then provides code/samples; explanation of what the code is doing comes next, and finally, the topic finishes with more details if you care to dive deeper. This is a nice approach that'll get you up and running quickly.I will point out that the code in the text is a subset of the overall text. So whereas something like a Deitel text provides a ton of code all in print, this cookbook text gives a necessary snippet and assumes you'll dive into the actual code (provided online) as needed. In my opinion, this is a good thing, but just be aware of this if you're not following how some stuff is working; just realize that there's more code provided that's not in the text.Unlike other texts that start from a "hello world" basic game and build into a single (or a few) larger game, this text (similar to other Packt cookbook texts), focuses on specific elements (like handling parallax scrolling, working with AndEngine entities, making a HUD, or handling collisions with Box2D). All of these topics are essential to making a 2D game, and you can drop in these concepts (and sample code) into your games rather quickly if you're using AndEngine. What's nice is that you're not just re-creating a single game throughout this text, but rather you're given lots of tricks and approaches to drop these essentials into your own game(s).I will caution you (as another reviewer stated) that this book presumes you know some basic game development concepts like design patterns (the singleton, object factory for examples) and resource pools (and why they're a good thing) among others. If you haven't picked these up earlier, then you'll need to take these ideas on faith or do a bit of background research to convince yourself these are valid approaches. But the upside is that if you're rusty on some of these concepts, this AndEngine cookbook text is an excellent, no-nonsense approach to getting going quickly. Also, be sure to check out the helpful PDF on how to set up your Android/AndEngine development environment/IDE in the code folder you download with the book; so look to this PDF file (downloaded with the code from the text) and follow it along if you need help getting your development environment set up.Since mobile is such an important and growing field, you should know something about Android development. If you want to see an engine that'll do all of the essentials and more, or if you've not done mobile/Android before, then check out AndEngine. And for the price of this book (especially the ecopy), the AndEngine Cookbook from Packt is a great choice to save you a lot of time as you dev your games.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.