Learning Cocos2d-JS Game Development
eBook - ePub

Learning Cocos2d-JS Game Development

Emanuele Feronato

Share book
  1. 188 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Learning Cocos2d-JS Game Development

Emanuele Feronato

Book details
Book preview
Table of contents
Citations

About This Book

Complete TIS Desc (HTML)

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Learning Cocos2d-JS Game Development an online PDF/ePUB?
Yes, you can access Learning Cocos2d-JS Game Development by Emanuele Feronato in PDF and/or ePUB format, as well as other popular books in Computer Science & Open Source Programming. We have over one million books available in our catalogue for you to explore.

Information

Learning Cocos2d-JS Game Development


Table of Contents

Learning Cocos2d-JS Game Development
Credits
Foreword
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
Downloading the color images of this book
Errata
Piracy
Questions
1. Hello World – A Cross-platform Game
Why should I make cross-platform games?
What Cocos2d-JS is and how it works
Requirements to run Cocos2d-JS
The structure of your Cocos2d-JS project
Hello Cross-World
Preloading and adding images
Removing images and changing the background color
Summary
2. Adding Interactivity – The Making of a Concentration Game
Creating multiple instances of game assets
Adding a gradient background
Extending the Sprite class beyond its capabilities
Making assets react to clicks and touches
Picking a tile as an initial attempt
Changing sprite images on the fly
Showing the tile picture
Shuffling the tiles and adding the score
Summary
3. Moving Sprites Around the Screen – An Endless Runner
Loading and placing graphic resources
Adding an endless scrolling background
Adding the spaceship
Controlling the spaceship
Adding asteroids
Asteroid versus spaceship collision
Invulnerability
Preventing the spaceship from flying off the screen
Adding particles
Summary
4. Learn about Swipes through the making of Sokoban
Loading graphic assets
Building a level
Detecting swipes
Completing the game
Summary
5. Become a Musical Maestro
Choosing sounds
Preloading sounds
Creating a sound menu
Managing music and sound effects
Summary
6. Controlling the Game with Virtual Pads
Overview of virtual pads
First things first – the game
Controlling the cart with ghost buttons
Controlling the cart with a virtual pad
Controlling the cart just with your finger
Summary
7. Adding Physics to Your Games Using the Box2D Engine
Before you start
Adding the Box2D engine to your project
Configuring the physics world
Adding bodies to the world
Updating sprite position as the world changes
Selecting and destroying world bodies
Checking for collisions among bodies
Summary
8. Adding Physics to Your Games Using the Chipmunk2D Engine
Adding the Chipmunk2D engine to your project
A physics game, without physics
Configuring the physics space
Adding bodies to the space
Updating Chipmunk2D space and using debug draw
Selecting and destroying space bodies
Checking for collisions among bodies
Using your own graphic assets
Summary
9. Creating Your Own Blockbuster Game – A Complete Match 3 Game
Setting up the game
Creating the board
Selecting and deselecting the first globe
Making globez chains
Backtracking
Removing globez
Making the globez fall down
Creating new globez
Bonus – using the drawing API for a visual feedback
Where to go now
Protect your code
Port your game on mobile devices as a native app
Publishing your game
Licensing your game
Staying up-to-date
Summary
Index

Learning Cocos2d-JS 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: January 2015
Production reference: 1070115
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78439-007-5
www.packtpub.com

Credits

Author
Emanuele Feronato
Reviewers
Pradyumna Doddala
Pavel Goodanets
Marc Estruch Tena
Jialong Zhai
Commissioning Editor
Ashwin Nair
Acquisition Editor
James Jones
Content Development Editor
Samantha Gonsalves
Technical Editor
Parag Topre
Copy Editor
Relin Hedly
Project Coordinator
Sanchita Mandal
Proofreaders
Simran Bhogal
Stephen Copestake
Maria Gould
Ameesha Green
Paul Hindle
Indexer
Rekha Nair
Production Coordinator
Alwin Roy
Cover Work
Alwin Roy

Foreword

Known by developers all over the world, Cocos2d-x has always endeavored to help developers build and port their games on iOS, Android, and many more native platforms. However, not many developers are aware that the Cocos2d-x team also provides an efficient game engine called Cocos2d-JS to assist users developing cross-native and web platform games with only one code base.
The year 2014 has certainly been a big year for Cocos2d-JS. It became more widely adopted by big companies all over the world; we've released a major version—3.0—and combined Cocos2d-html5 and Cocos2d-x JSB (JavaScript Binding) into Cocos2d-JS. It supplies your game with cross-browser and cross-platform capabilities accompanied by complete Cocos2d-x features, complete tool chain support, and simple friendly APIs. Furthermore, we reinvented the workflow for all platforms, providing a consistent development experience for whichever platform you want to distribute it to. As a result, the Code once, run everywhere principle is easily achieved and feels natural in Cocos2d-JS. With one single JavaScript code base, you can run your game on all web browsers and native platforms, including Mac OS, Windows, iOS, and Android. This will allow your game to deliver in almost all channels of distribution for better opportunities.
Today, I'm more than grateful to witness the creation of this extraordinary book. I believe this book will help us by building a bridge to our developers around the world so they can step over the language barrier. I'd love to express my special thanks...

Table of contents