SlideShare a Scribd company logo
Build a Game in 60 minutes
PeopleSpace, Irvine CA 24 May 2016
Build a Game in 60 minutes
Code and Slides
http://www.slideshare.net/rockncoder/build-a-game-
in-60-minutes
https://github.com/Rockncoder/oldschool
Troy Miles
Troy Miles
Over 37 years of
programming experience
Speaker and author
Author of jQuery Essentials
rockncoder@gmail.com
@therockncoder
Build a Game in 60 minutes
Cocos2d-x: Introduction
What is Cocos2d-x?
Open source game engine under MIT license
It is optimized for 2D graphics using OpenGL
Used by more than 400,000 developers worldwide
History
2008 Ricardo Quesada in Argentina creates Cocos2d
Ported to iPhone with the opening of the iPhone App
Store
2010 Zhe Wang in China forks it creating Cocos2d-x
2013 Ricardo joins Cocos2d-x team
12 May 2016 version 3.11 released
Target Platforms
Android
iOS (iPhone + iPad)
Mac OS X
Windows Phone 8
Windows 7
Development Platforms
Visual Studio 2012+ (Windows)
Xcode 4.6+ (Mac)
CMake 2.6+ (Ubuntu)
All platforms need Python v2.7.x (not 3!)
Development Languages
C++
Lua
JavaScript (all except WP8)
Why JavaScript?
Arguably the most popular programming language
It is universal
It is fast
Way easier to learn than C++
Mandatory Tools
iOS / Mac OS X apps require Xcode and a Mac
Windows / WP8 apps require VS and a PC
Titles using Cocos2d-x
Text
Avengers Alliance
Marvel Entertainment
Text
Family Guy: The Quest for Stuff
TinyCo, Inc.
Diamond
Dash
Wooga
Star Wars:
Tiny Death
Star
LucasArts
BADLAND
Frogmind
Build a Game in 60 minutes
Key Points	
Cocos2d has been around since 2008
Cocos2d-x uses C++ for speed
A lot of big name titles use it
It has always been free and always will be
Cocos2d-x: Installation
Keep in mind…
I am using a Mac, but Cocos2D-x is cross platform
Everything will work on Windows and Linux
Mac Development
Python 2.7.x
Apple Xcode
(Jetbrains’ AppCode)
Windows Development
Python 2.7.x
Visual Studio 2012+
Windows Phone SDK 8
cocos2d-x.org
Tutorials
Forum
Blog
Downloads
Download
http://www.cocos2d-x.org/download
Under the column, Cocos2d-x,
Click, “DOWNLOAD V3.11”
Unzip it
Installation
From terminal or command prompt
cd to the root of the directory
setup.py
(will modify your path and other env variables)
open the project for your environment
Key Points
Installing cocos2d-x is pretty easy
Everything is done from the command line
Cocos2d-x: Feature Overview
Build a Game in 60 minutes
JavaScript
Uses Mozilla’s SpiderMonkey JS Engine v33
Released 14 Oct 2014
Same engine used in FireFox 33
Support a lot of ES6 features
(except templates strings)
Widgets
Button
CheckBox
ListView
Slider
TextField
Audio
Sound effects
Background music
CocosDenshion library (Open AL)
Support audio is platform dependent
Physics
Chipmunk2D
Portable 2-dimensional real-time rigid body physics engine
Written in C99 by Scott Lembcke
Box2d
Free open source 2-dimensional physics simulator engine
Written in C++ by Erin Catto
Published under the zlib license
Network
HTTP + SSL
WebSocket API
XMLHttpRequest API
User Input
Touch/Accelerometer on mobile devices
Touch/Mouse/Keyboard on desktop
Game controller support
2D Graphics
Transitions between scenes
Sprites and Sprite Sheets
Effects: Lens, Ripple, Waves, Liquid, etc.
Transformation Actions: Move, Rotate, Scale, Fade, Tint,
etc.
Composable actions: Sequence, Spawn, Repeat,
Reverse
2D Graphics
Ease Actions: Exp, Sin, Cubic, Elastic, etc.
Misc actions: CallFunc, OrbitCamera, Follow, Tween
Particle system
Skeleton Animations: Spine and Adobe DragonBone
Fast font rendering using Fixed and Variable width fonts
2D Graphics
TrueType fonts
Tile Map support: Orthogonal, Isometric and
Hexagonal
Parallax scrolling
Motion Streak
Render To Texture
Right handed coordinate system
Different than web
Origin (0,0) located at lower
left hand of screen
x position increases going
right
y position increases going up
max x,y at upper right hand
corner
Let’s make a game
Cocos command options
new - creates a new game
run - compile, deploy, and run on game on target
deploy - deploy game to target
compile - compiles game
luacompile - minifies Lua files and compiles
jscompile - minifies JS files and compiles
Cocos command options
-h, —help - Shows the help
-v, —version - Shows the current version
Creating a new game
Open the cmd window
Validate that cocos is in your path, cocos <enter>
cocos new gamename -p com.company.name -l js
new command explained
MyGame: name of your project
-p com.mycompany.mygame: package name
-l js: programming language used for the project, valid
values are: cpp, lua, and js
Directory Structure
Classes
cocos2d
Resources
Platform directories
Class Directory
AppDelegate initializes
cocos2d-x
HelloWorldScene is
where your game begins
Hello World
Cocos2D-x ships as
source code
Build it to compile the
libraries
Bootup on Mac
launches from main.cpp
calls AppDelegate.cpp
(starts up Cocos2D-x)
calls main.js
(launches your scene)
Graphics Diagnostics
configured in project.json
82 <-- number of draw calls
0.016 <-- time it took to render the frame
60.0 <-- frames per second
Don’t forget
Add JavaScript files to the project.json
Add resources (images/sound/music) to resources.js
Forgetting to add them is a very common bug
Lexicon
Director
Node
Scene
Layer
Sprite
Action
Particle
Event
Adding Scenes
Scenes are actually derived from the Layer class
Add scene for main, game, pause, end game
Add colors to scenes
Add transitions
The Game Loop
The central component of any game
Allows game to run smoothly regardless of user input
Allows game to run at same speed regardless of
machine
Game Loop Reality
In the scene init add, 

this.scheduleUpdate()
Add an update method, 

HelloWorld::update(float dt)
The update method should be as fast as possible
Steps
Add a background
Add a hero
Move the hero
Detect touches
Fire bullets
Add enemy
Animate enemy
Detect collision
Give points
Detect end of game
Steps
Adding sound
Adding music
Adding scenes
Resources
http://www.nosoapradio.us/
http://www.freesound.org/
http://spritedatabase.net/
http://opengameart.org/
http://www.lostgarden.com/search/label/free%20game
%20graphics
More resources
http://www.spriters-resource.com/
https://github.com/cocos2d/cocos2d-js-tests/tree/
master/games
https://github.com/dalinaum/chukong-cocos-docs/
tree/master/tutorial/framework/html5/parkour-game-
with-javascript-v3.0
Code and Slides
http://www.slideshare.net/rockncoder/build-a-game-
in-60-minutes
https://github.com/Rockncoder/oldschool
Summary
Cocos2d-x is a free open source game engine
It supports Android, iOS, Windows and Mac
Questions?

More Related Content

PDF
Quick & Dirty & MEAN
PDF
Game Design and Development Workshop Day 1
PDF
Linux Containers (LXC)
PDF
The Ring programming language version 1.6 book - Part 7 of 189
RTF
R snippet
PDF
From Zero to Application Delivery with NixOS
PPTX
How to write memory efficient code?
PDF
Introduction to Docker (and a bit more) at LSPE meetup Sunnyvale
Quick & Dirty & MEAN
Game Design and Development Workshop Day 1
Linux Containers (LXC)
The Ring programming language version 1.6 book - Part 7 of 189
R snippet
From Zero to Application Delivery with NixOS
How to write memory efficient code?
Introduction to Docker (and a bit more) at LSPE meetup Sunnyvale

What's hot (20)

PDF
App container rkt
PDF
Programming IoT Gateways in JavaScript with macchina.io
PPTX
Docker Warsaw Meetup 12/2017 - DockerCon 2017 Recap
PDF
From zero to Docker
PDF
Build and Run Containers With Lazy Pulling - Adoption status of containerd St...
PPTX
Tech talk on docker with demo
PDF
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
PDF
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
PDF
Docker 原理與實作
PDF
A Brief Introduction to the Qt Application Framework
PPTX
NDK Introduction
PDF
Clojure ♥ cassandra
PDF
Containerizing Web Application with Docker
PDF
Docker as an every day work tool
PDF
The overview of lazypull with containerd Remote Snapshotter & Stargz Snapshotter
PDF
[KubeCon EU 2020] containerd Deep Dive
PDF
Functional Operations (Functional Programming at Comcast Labs Connect)
PDF
Programming IoT with Docker: How to Start?
PDF
How to debug the pod which is hard to debug (디버그 하기 어려운 POD 디버그 하기)
PDF
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
App container rkt
Programming IoT Gateways in JavaScript with macchina.io
Docker Warsaw Meetup 12/2017 - DockerCon 2017 Recap
From zero to Docker
Build and Run Containers With Lazy Pulling - Adoption status of containerd St...
Tech talk on docker with demo
Cgroups, namespaces, and beyond: what are containers made from? (DockerCon Eu...
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
Docker 原理與實作
A Brief Introduction to the Qt Application Framework
NDK Introduction
Clojure ♥ cassandra
Containerizing Web Application with Docker
Docker as an every day work tool
The overview of lazypull with containerd Remote Snapshotter & Stargz Snapshotter
[KubeCon EU 2020] containerd Deep Dive
Functional Operations (Functional Programming at Comcast Labs Connect)
Programming IoT with Docker: How to Start?
How to debug the pod which is hard to debug (디버그 하기 어려운 POD 디버그 하기)
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Ad

Similar to Build a Game in 60 minutes (20)

PDF
Cocos2d-x C++ Windows 8 &Windows Phone 8
PDF
Introduction to Mobile Game Programming with Cocos2d-JS
PDF
Cross Platform Game Programming with Cocos2d-js
PDF
Programmers guide
PPTX
20151120 ian cocos2d js
PPT
Hub102 - Lesson 6 - Cocos2d-js
PDF
Game development with Cocos2d-x Engine
PDF
iOS Game Development: When Cocoa Met Cocos...
PDF
Cocos2d 소개 - Korea Linux Forum 2014
PPTX
Developing native cross platform games on Cocos2dx2
PPTX
Cocos2d for beginners
PPTX
Introduction to cocos2d-x
PPT
Cocos2d for i phone(second) copy
PDF
02 evolution innovation and participation
PDF
Cocos2d game programming 2
PDF
Introduction to CocosSharp
PDF
Cocos2d programming
PPTX
PDF
For cocos2d jpn devcon
PDF
Cocos2dx
Cocos2d-x C++ Windows 8 &Windows Phone 8
Introduction to Mobile Game Programming with Cocos2d-JS
Cross Platform Game Programming with Cocos2d-js
Programmers guide
20151120 ian cocos2d js
Hub102 - Lesson 6 - Cocos2d-js
Game development with Cocos2d-x Engine
iOS Game Development: When Cocoa Met Cocos...
Cocos2d 소개 - Korea Linux Forum 2014
Developing native cross platform games on Cocos2dx2
Cocos2d for beginners
Introduction to cocos2d-x
Cocos2d for i phone(second) copy
02 evolution innovation and participation
Cocos2d game programming 2
Introduction to CocosSharp
Cocos2d programming
For cocos2d jpn devcon
Cocos2dx
Ad

More from Troy Miles (20)

PDF
Fast C++ Web Servers
PDF
Node Boot Camp
PDF
AWS Lambda Function with Kotlin
PDF
React Native One Day
PDF
React Native Evening
PDF
Intro to React
PDF
React Development with the MERN Stack
PDF
Angular Application Testing
PDF
ReactJS.NET
PDF
What is Angular version 4?
PDF
Angular Weekend
PDF
From MEAN to the MERN Stack
PDF
Functional Programming in JavaScript
PDF
Functional Programming in Clojure
PDF
MEAN Stack Warm-up
PDF
The JavaScript You Wished You Knew
PDF
A Quick Intro to ReactiveX
PDF
JavaScript Foundations Day1
PDF
AngularJS Beginner Day One
PDF
AngularJS on Mobile with the Ionic Framework
Fast C++ Web Servers
Node Boot Camp
AWS Lambda Function with Kotlin
React Native One Day
React Native Evening
Intro to React
React Development with the MERN Stack
Angular Application Testing
ReactJS.NET
What is Angular version 4?
Angular Weekend
From MEAN to the MERN Stack
Functional Programming in JavaScript
Functional Programming in Clojure
MEAN Stack Warm-up
The JavaScript You Wished You Knew
A Quick Intro to ReactiveX
JavaScript Foundations Day1
AngularJS Beginner Day One
AngularJS on Mobile with the Ionic Framework

Recently uploaded (20)

DOCX
The Five Best AI Cover Tools in 2025.docx
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
System and Network Administration Chapter 2
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
medical staffing services at VALiNTRY
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
AI in Product Development-omnex systems
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Complete React Javascript Course Syllabus.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
history of c programming in notes for students .pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
ai tools demonstartion for schools and inter college
PPTX
Essential Infomation Tech presentation.pptx
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Online Work Permit System for Fast Permit Processing
The Five Best AI Cover Tools in 2025.docx
2025 Textile ERP Trends: SAP, Odoo & Oracle
System and Network Administration Chapter 2
Softaken Excel to vCard Converter Software.pdf
Operating system designcfffgfgggggggvggggggggg
ManageIQ - Sprint 268 Review - Slide Deck
medical staffing services at VALiNTRY
Adobe Illustrator 28.6 Crack My Vision of Vector Design
AI in Product Development-omnex systems
Wondershare Filmora 15 Crack With Activation Key [2025
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PTS Company Brochure 2025 (1).pdf.......
Complete React Javascript Course Syllabus.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
history of c programming in notes for students .pptx
Design an Analysis of Algorithms II-SECS-1021-03
ai tools demonstartion for schools and inter college
Essential Infomation Tech presentation.pptx
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Online Work Permit System for Fast Permit Processing

Build a Game in 60 minutes