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
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Cocos2d-JS Game Development

You're reading from   Learning Cocos2d-JS Game Development Learn to create robust and engaging cross-platform HTML5 games using Cocos2d-JS

Arrow left icon
Product type Paperback
Published in Jan 2015
Publisher
ISBN-13 9781784390075
Length 188 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Emanuele Feronato Emanuele Feronato
Author Profile Icon Emanuele Feronato
Emanuele Feronato
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Hello World – A Cross-platform Game 2. Adding Interactivity – The Making of a Concentration Game FREE CHAPTER 3. Moving Sprites Around the Screen – An Endless Runner 4. Learn about Swipes through the making of Sokoban 5. Become a Musical Maestro 6. Controlling the Game with Virtual Pads 7. Adding Physics to Your Games Using the Box2D Engine 8. Adding Physics to Your Games Using the Chipmunk2D Engine 9. Creating Your Own Blockbuster Game – A Complete Match 3 Game Index

Creating multiple instances of game assets


The first thing you have to do in the making of a Concentration game is draw the tiles that you will use in the game. Here are the pictures used for the covered tiles and the eight different tiles that could be potentially matched, all saved in the assets folder, as explained in the previous chapter:

Each tile is a 64 x 64 PNG file, where the covered tile is called cover.png, while the tile to be matched is named with a progressive number from 0 to 7: tile_0, tile_1, until tile_7. This is because the actual board tile values will be stored in an array whose values will range from 0 to 7, and it will be easy to assign value 0 to tile_0, value 1 to tile_1, and so on.

With these nine files in the assets folder, you are ready to load them, thanks to the loadassets.js file located in the src folder of our project:

var gameResources = ["assets/cover.png",
  "assets/tile_0.png",
  "assets/tile_1.png",
  "assets/tile_2.png",
  "assets/tile_3.png",
  "assets...
You have been reading a chapter from
Learning Cocos2d-JS Game Development
Published in: Jan 2015
Publisher:
ISBN-13: 9781784390075
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image