Building Android Games with Cocos2d-x
eBook - ePub

Building Android Games with Cocos2d-x

Raydelto Hernandez

Partager le livre
  1. 160 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Building Android Games with Cocos2d-x

Raydelto Hernandez

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Building Android Games with Cocos2d-x est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Building Android Games with Cocos2d-x par Raydelto Hernandez en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Computer Science et Programming in Java. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2015
ISBN
9781785283833

Building Android Games with Cocos2d-x


Table of Contents

Building Android Games with Cocos2d-x
Credits
Foreword
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 Your Development Environment
Cocos2d-x overview
Setting up Java
Setting up the Android SDK
Downloading the Android SDK
Downloading Eclipse
Setting up the Eclipse ADT plugin
Setting up the Android Native Development Kit
Setting up Apache Ant
Setting up Python
Setting up Cocos2d-x
Creating your first project
Setting up the Eclipse IDE
Template code walk-through
Java classes
Android application configuration
C++ classes
Scenes
Summary
2. Graphics
Creating scenes
Understanding Layers
Using the director
Pausing the game
Organizing our resources files
Creating our pause scene header file
Creating the pause scene implementation file
Transitions
Understanding nodes
Understanding sprites
Creating sprites
Positioning sprites
Setting anchor points
Understanding the Cocos2d-x coordinate system
Adding sprites to the scene
Positioning sprites outside the visible area
Positioning the player sprite
Understanding actions
Moving sprites
Creating sequences
Animating sprites
Improving performance with sprite sheets
Game menus
Handling multiple screen resolutions
Putting everything together
Summary
3. Understanding Game Physics
Setting up the physics world
Collision detection
Handling gravity
Handling physics properties
Applying velocity
Linear damping
Applying force
Applying impulse
Applying torque
Putting everything together
Summary
4. User Input
Understanding the Event Dispatcher mechanism
Handling the touch event
Handling multi-touch events
Handling accelerometer events
Keeping the screen alive
Handling the Android back key pressed event
Putting everything together
Summary
5. Handling Text and Fonts
Creating TrueType font labels
Creating our GameOverScene
Calling our GameOverScene when a player loses
Customizing the GameOverScene
Adding label effects
Creating system fonts
Creating bitmap font labels
Adding more bombs to our game
Putting everything together
Summary
6. Audio
Playing background music and sound effects
Modifying audio properties
Handling audio when leaving the game
The new audio engine
New features included in the new audio engine
Adding a mute button to our game
Putting everything together
Summary
7. Creating Particle Systems
Creating collections of the Cocos2d-x objects
Exploding bombs
Adding particle systems to our game
Configuring the particle systems
Creating customized particle systems
Putting everything together
Summary
8. Adding Native Java Code
Understanding the Cocos2d-x structure for the Android platform
Understanding the JNI capabilities
Adding Java code to the Cocos2d-x game
Adding ads to the game by inserting Java code
Configuring the environment
Modifying the Android manifest
Adding the Java code
Putting everything together
Summary
Index

Building Android Games with Cocos2d-x

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: March 2015
Production reference: 1240315
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-383-3
www.packtpub.com
Cover image by Ricardo Diaz ()

Credits

Author
Raydelto Hernandez
Reviewers
Alejandro Duarte
Emanuele Feronato
Akihiro Matsuura
Luma
Commissioning Editor
Veena Pagare
Acquisition Editor
Sam Wood
Content Development Editor
Samantha Gonsalves
Technical Editor
Manan Patel
Copy Editor
Deepa Nambiar
Project Coordinator
Sanchita Mandal
Proofreaders
Maria Gould
Julie Jackson
Joyce Littlejohn
Indexer
Priya Sane
Production Coordinator
Komal Ramchandani
Cover Work
Komal Ramchandani

Foreword

I really like this book and the work Raydelto did writing it. This book teaches you from scratch how to develop games using Cocos2d-x and how the JNI works. I know this book will be useful for anyone who is new in this framework or has experience in it. I read each chapter and I can say that Raydelto wrote each chapter well, so I'm sure this book contains his passion and each reader will enjoy and learn because it is an excellent book.
Carlos Piñan
CTO, Vitrum Games

About the Author

Raydelto Hernandez is a software engineer and university professor living in Santo Domingo, Dominican Republic. He has developed games for BlackBerry 10, Android, and iOS. He currently teaches topics related to game development at INTEC University.
At the age of 22, he started teaching at Las Americas Institute of Technology, where he earned the Professor of the Year award many times. Then he the became director of the software development center. He has also taught at UNAPEC University, UNIBE University, and INTEC University, where he is currently a research professor.
He is a BlackBerry Certified Builder, Zend Certified Engineer, Certified Java programmer, CompTIA A+ professional, and Microsoft Technology Associate.
Raydelto has posted on YouTube dozens of video tutorials on different programming environments, which are also available on his website at www.raydelto.org. Here, you can also find information about his open source projects.
Raydelto has founded two technology companies, Soluciones GBH (in 2005) and AST Technology (in 2008), which develop software for all platforms.

About the Reviewers

Alejandro Duarte has been coding since 1994, when he was 13 years old, using languages such as Basic, C, C++, Assembler, C#, PHP, Java, Groovy, and Lua. He focuses mainly on Java technologies for enterprise applications, but always keeps an eye on the video game development industry and technologies. He has collaborated with several open source and closed source projects based on Cocos2d-x, Processing, Irrlicht Engine, and the Allegro library.
Alejandro has worked for companies in Colombia and the United Kingdom as a software developer and consultant. He is the author of Vaadin 7 UI Design by Example: Beginner's Guide, and a technical reviewer for Cocos2d-x by Example Beginner's Guide. He maintains several open source projects hosted...

Table des matiĂšres