SlideShare a Scribd company logo
Cross Platform Game
Programming with Cocos2d-x
(Windows 8)
SoCal Code Camp - 15 November 2014
Troy Miles
Cocos2d-x C++ Windows 8 &Windows Phone 8
Who am I?
Troy Miles
Wrote a few hit computer games in the 80’s and 90’s
rockncoder@gmail.com
https://github.com/Rockncoder
http://www.slideshare.net/rockncoder
@therockncoder
Cocos2d-x C++ Windows 8 &Windows Phone 8
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 branches it creating
Cocos2d-x
2013 Ricardo joins Cocos2d-x team
Target Platforms
Windows Phone 8+
iPhone 5+
Android 2.3+
Windows 7+
Mac OS X 10.6+
Development Platforms
Windows 7+, VS 2012+
Mac OS X 10.7+, Xcode 4.6+
Ubuntu 12.10+, CMake 2.6+
All platforms need Python 2.7.5 (not 3!)
Development Languages
C++
Lua
JavaScript (all except WP8)
Why C++?
It is the most popular game programming language
It is universal
It is fast
It really isn’t that hard
C++ 11 makes it even better
Mandatory Tools
In order to build iPhone apps, you need Xcode
In order to build Windows Phone apps, you need
Visual Studio
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
Cocos2d-x C++ Windows 8 &Windows Phone 8
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
Windows Development
Python 2.7.5
Visual Studio 2012+
Windows Phone SDK 8
cocos2d-x.org
Tutorials
Forum
Blog
Downloads
Download & Installation
http://www.cocos2d-x.org/download
Click “Looking for an older version?”
Click “v3.2 Jul. 18, 2014”
Unzip it
v2 vs v3
Current version is 3.2, 3.3 is in beta
Version 3.0 is a re-write using C++ 11
Many V2 classes have been deprecated and renamed
Updated directory structure
Better command line tooling
Drops Xcode templates
Windows 8 Path
Settings -> Control Panel -> System -> Advanced system
settings
Environmental Variables…
System variables modal
Path
Edit...
Add "[cocos2d-x root]toolscocos2d-consolebin"
Running C++ Tests
Open file "cocos2d-wp8.vc2012.sln" in build directory
Make cpp-tests the StartUp project
Compile and run
Key Points
Cocos2d-x version 3 was a complete re-write
Installing cocos2d-x on windows is pretty easy
Getting the C++ Test app to compile and run is
essential
Cocos2d-x: Feature Overview
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
C++ Test Demo
Lexicon
Director
Node
Scene
Layer
Sprite
Action
Particle
Event
Key Points
Cocos2d-x is feature packed
Its classes follow a logical progression which makes
them easy to learn
Cocos2d-x: Building 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 cpp
new command explained
MyGame: name of your project
-p com.MyCompany.MyGame: package name
-l cpp: programming language used for the project,
valid values are: cpp, lua, and js
Directory Structure
Classes
cocos2d
Resources
Platform directories
WP8 Platform Directory
The solution file
Leave everything else
alone
Class Directory
AppDelegate initializes
cocos2d-x
HelloWorldScene is
where your game begins
Hello World
Use Visual Studio to
build and deploy the
game
Best to use actual
device
Debugging
Right click on project name
Click on Properties
Click on Debug tab (left side, second from top)
Under UI Task, select Native Only
Graphics Diagnostics
82 <-- number of draw calls
0.016 <-- time it took to render the frame
60.0 <-- frames per second
In the file, AppDelegate.cpp find the line:

director->setDisplayStats(true);
Memory Diagnostics
Windows Phone adds a Memory Diagnostics
First value is current memory usage, second is the
peak
Like the Graphics Diagnostics, it can be removed
In MainPage.xaml.cs, near the top of the file
Comment out definition of DISPLAY_MEMORY
Examining the code
AppDelegate.cpp initializes cocos2d-x and launches
your game
HelloWorldScene.cpp is your game
Initially it doesn’t do much
Adding Scenes
Scenes are actually derived from the Layer class
Add scene for main, game, pause, end game
Add colors to scenes
Add transitions
Adding Classes
For cross platform-ness we want preserve our directory
structure
Visual Studio needs to be tricked
We add the class, remove it, move it to correct
directory, then add it back
Class Template
Most of the classes we
add look like this
Prefer using #ifndef over
#pragma once
Remember to include
base class
CREATE_FUNC
Unlike Java, C#, or even
JavaScript, C++
programs manage their
own memory
cocos has memory
manage
CREATE_FUNC adds it
to your class
How the Scene is launched
Currently we are still using the HelloWorldScene
instead of our fancy new MainScene
Open file AppDelegate.cpp, find:
auto scene = HelloWorld::createScene();
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, 

void 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
Animate Hero
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
Summary
Cocos2d-x is a free open source game engine
It supports Windows, WP8, iOS, Android, and more
https://github.com/Rockncoder/PlaneGame2
Contacting Me
@therockncoder
rockncoder@gmail.com
https://github.com/Rockncoder
http://www.slideshare.net/rockncoder
Text
http://spkr8.com/t/39721
Please rate this talk!

More Related Content

What's hot (20)

PPTX
Unity 5 Overview
Shahed Chowdhuri
 
PPTX
PRESENTATION ON Game Engine
Diksha Bhargava
 
PPTX
ธีระศักดิ์ ขำแห้ว เลขที่ 9
Pop Areerob
 
PPTX
Unity - Game Engine
Geeks Anonymes
 
PPT
What Is A Game Engine
Seth Sivak
 
PPTX
Game engines and Their Influence in Game Design
Prashant Warrier
 
PPTX
CreateJS
Jorge Solis
 
PPTX
Game development unity
Vicky Fazlurrahman
 
PDF
Mobile Game Development in Unity
Hakan Saglam
 
PPTX
ECS: Making the Entity Debugger - Unite LA
Unity Technologies
 
PPTX
WP7 HUB_XNA
MICTT Palma
 
PPTX
WP7 HUB_XNA overview
MICTT Palma
 
PDF
Multiplayer Networking Game
Tanmay Krishna
 
PDF
Game Programming I - GD4N
Francis Seriña
 
DOCX
Environment presentation
luisfvazquez1
 
PPTX
Unity Game Engine - Basics
FirosK2
 
PPTX
Hands On with the Unity 5 Game Engine! - Andy Touch - Codemotion Roma 2015
Codemotion
 
PPT
Data Driven Game development
Kostas Anagnostou
 
PPSX
Akshay-UNIT 20-LO-1,2,3&4-FINAL
Akshay
 
PDF
What Would Blizzard Do
Nick Pruehs
 
Unity 5 Overview
Shahed Chowdhuri
 
PRESENTATION ON Game Engine
Diksha Bhargava
 
ธีระศักดิ์ ขำแห้ว เลขที่ 9
Pop Areerob
 
Unity - Game Engine
Geeks Anonymes
 
What Is A Game Engine
Seth Sivak
 
Game engines and Their Influence in Game Design
Prashant Warrier
 
CreateJS
Jorge Solis
 
Game development unity
Vicky Fazlurrahman
 
Mobile Game Development in Unity
Hakan Saglam
 
ECS: Making the Entity Debugger - Unite LA
Unity Technologies
 
WP7 HUB_XNA
MICTT Palma
 
WP7 HUB_XNA overview
MICTT Palma
 
Multiplayer Networking Game
Tanmay Krishna
 
Game Programming I - GD4N
Francis Seriña
 
Environment presentation
luisfvazquez1
 
Unity Game Engine - Basics
FirosK2
 
Hands On with the Unity 5 Game Engine! - Andy Touch - Codemotion Roma 2015
Codemotion
 
Data Driven Game development
Kostas Anagnostou
 
Akshay-UNIT 20-LO-1,2,3&4-FINAL
Akshay
 
What Would Blizzard Do
Nick Pruehs
 

Viewers also liked (6)

PPTX
Top Apps for Android, Blackberry, Window & i-phones
Parul Gupta
 
PPTX
How to send text message in windows phone in lumia 625, lumia 520, lumia 720,...
ajithnandanam
 
PPTX
How to add attachments in text message in lumia 625, lumia 520, lumia 720, lu...
ajithnandanam
 
PPTX
Research on fonts
gq34khan
 
PPT
Myanmar fonts & unicode
Ngwe Tun
 
PDF
Memento: Time Travel for the Web
Herbert Van de Sompel
 
Top Apps for Android, Blackberry, Window & i-phones
Parul Gupta
 
How to send text message in windows phone in lumia 625, lumia 520, lumia 720,...
ajithnandanam
 
How to add attachments in text message in lumia 625, lumia 520, lumia 720, lu...
ajithnandanam
 
Research on fonts
gq34khan
 
Myanmar fonts & unicode
Ngwe Tun
 
Memento: Time Travel for the Web
Herbert Van de Sompel
 
Ad

Similar to Cocos2d-x C++ Windows 8 &Windows Phone 8 (20)

PDF
Build a Game in 60 minutes
Troy Miles
 
PDF
Introduction to Mobile Game Programming with Cocos2d-JS
Troy Miles
 
PDF
Cross Platform Game Programming with Cocos2d-js
Troy Miles
 
PPT
Maemo Development Environment
jtukkine
 
PPT
Iphone and Ipad development Game with Cocos2D
creagamers
 
PPTX
XHackers GameDev / Android LolliPop / Xamarin Forms
Vidyasagar Machupalli
 
PPTX
C++Basics2022.pptx
Danielle780357
 
PDF
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
DroidConTLV
 
PPTX
Intro to JavaScript Tooling in Visual Studio Code
ColdFusionConference
 
PPTX
Developing native cross platform games on Cocos2dx2
BeMyApp
 
PDF
Best Programming Course in Jalandhar - TechCADD Computer Education
p94549974
 
PPTX
C++ helps you to format the I/O operations like determining the number of dig...
bhargavi804095
 
PDF
Targeting Android with Qt
Espen Riskedal
 
PPTX
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
bhargavi804095
 
PPTX
Introduction-to-C-Part-1.pptx
NEHARAJPUT239591
 
PPTX
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
meharikiros2
 
DOC
Introduction-to-C-Part-1 (1).doc
MayurWagh46
 
PPT
Synapse india dotnet framework development or c
Synapseindiappsdevelopment
 
PDF
Introduction-to-C-Part-1.pdf
AnassElHousni
 
PPT
Cocos2d for i phone(second) copy
Arafat X
 
Build a Game in 60 minutes
Troy Miles
 
Introduction to Mobile Game Programming with Cocos2d-JS
Troy Miles
 
Cross Platform Game Programming with Cocos2d-js
Troy Miles
 
Maemo Development Environment
jtukkine
 
Iphone and Ipad development Game with Cocos2D
creagamers
 
XHackers GameDev / Android LolliPop / Xamarin Forms
Vidyasagar Machupalli
 
C++Basics2022.pptx
Danielle780357
 
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
DroidConTLV
 
Intro to JavaScript Tooling in Visual Studio Code
ColdFusionConference
 
Developing native cross platform games on Cocos2dx2
BeMyApp
 
Best Programming Course in Jalandhar - TechCADD Computer Education
p94549974
 
C++ helps you to format the I/O operations like determining the number of dig...
bhargavi804095
 
Targeting Android with Qt
Espen Riskedal
 
C++ was developed by Bjarne Stroustrup, as an extension to the C language. cp...
bhargavi804095
 
Introduction-to-C-Part-1.pptx
NEHARAJPUT239591
 
Introduction-to-C-Part-1 JSAHSHAHSJAHSJAHSJHASJ
meharikiros2
 
Introduction-to-C-Part-1 (1).doc
MayurWagh46
 
Synapse india dotnet framework development or c
Synapseindiappsdevelopment
 
Introduction-to-C-Part-1.pdf
AnassElHousni
 
Cocos2d for i phone(second) copy
Arafat X
 
Ad

More from Troy Miles (20)

PDF
Fast C++ Web Servers
Troy Miles
 
PDF
Node Boot Camp
Troy Miles
 
PDF
AWS Lambda Function with Kotlin
Troy Miles
 
PDF
React Native One Day
Troy Miles
 
PDF
React Native Evening
Troy Miles
 
PDF
Intro to React
Troy Miles
 
PDF
React Development with the MERN Stack
Troy Miles
 
PDF
Angular Application Testing
Troy Miles
 
PDF
ReactJS.NET
Troy Miles
 
PDF
What is Angular version 4?
Troy Miles
 
PDF
Angular Weekend
Troy Miles
 
PDF
From MEAN to the MERN Stack
Troy Miles
 
PDF
Functional Programming in JavaScript
Troy Miles
 
PDF
Functional Programming in Clojure
Troy Miles
 
PDF
MEAN Stack Warm-up
Troy Miles
 
PDF
The JavaScript You Wished You Knew
Troy Miles
 
PDF
Game Design and Development Workshop Day 1
Troy Miles
 
PDF
Quick & Dirty & MEAN
Troy Miles
 
PDF
A Quick Intro to ReactiveX
Troy Miles
 
PDF
JavaScript Foundations Day1
Troy Miles
 
Fast C++ Web Servers
Troy Miles
 
Node Boot Camp
Troy Miles
 
AWS Lambda Function with Kotlin
Troy Miles
 
React Native One Day
Troy Miles
 
React Native Evening
Troy Miles
 
Intro to React
Troy Miles
 
React Development with the MERN Stack
Troy Miles
 
Angular Application Testing
Troy Miles
 
ReactJS.NET
Troy Miles
 
What is Angular version 4?
Troy Miles
 
Angular Weekend
Troy Miles
 
From MEAN to the MERN Stack
Troy Miles
 
Functional Programming in JavaScript
Troy Miles
 
Functional Programming in Clojure
Troy Miles
 
MEAN Stack Warm-up
Troy Miles
 
The JavaScript You Wished You Knew
Troy Miles
 
Game Design and Development Workshop Day 1
Troy Miles
 
Quick & Dirty & MEAN
Troy Miles
 
A Quick Intro to ReactiveX
Troy Miles
 
JavaScript Foundations Day1
Troy Miles
 

Recently uploaded (20)

PDF
How Agentic AI Networks are Revolutionizing Collaborative AI Ecosystems in 2025
ronakdubey419
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PDF
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PDF
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PDF
SAP GUI Installation Guide for Windows | Step-by-Step Setup for SAP Access
SAP Vista, an A L T Z E N Company
 
PDF
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PPTX
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
PDF
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
PPT
Brief History of Python by Learning Python in three hours
adanechb21
 
PDF
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
How Agentic AI Networks are Revolutionizing Collaborative AI Ecosystems in 2025
ronakdubey419
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Presentation about variables and constant.pptx
kr2589474
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
SAP GUI Installation Guide for Windows | Step-by-Step Setup for SAP Access
SAP Vista, an A L T Z E N Company
 
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
Summary Of Odoo 18.1 to 18.4 : The Way For Odoo 19
CandidRoot Solutions Private Limited
 
Brief History of Python by Learning Python in three hours
adanechb21
 
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 

Cocos2d-x C++ Windows 8 &Windows Phone 8