SlideShare a Scribd company logo
Cocos2d-x & HTML5
胡坤 Google Chrome/HTML5 开发技术推广经理
林顺 Cocos2d-html5 核心开发者




                           Google Confidential and Proprietary   1
HTML5游戏引擎 之 资源加载




                   Google Confidential and Proprietary   2
Cocos2d-HTML5的设计思想




                     Google Confidential and Proprietary   3
HTML5游戏引擎 之 性能

•  Update & Draw

•  > 60帧 = Kill Browser

•  Inner Timer à Fixed Tick

•  Canvas in Canvas




                               Google Confidential and Proprietary   4
Cocos2d-HTML5 内部时钟
内部时钟的实现,保证固定的步长
       Loop1           Loop2   Loop3       Loop n




        t0               t1     t2              t

               S =S0+ t *v;




                                       Google Confidential and Proprietary   5
HTML5游戏引擎 之 兼容性




                  Google Confidential and Proprietary   6
Cocos2d-HTML5的设计思想




                     Google Confidential and Proprietary   7
Cocos2d-HTML5的设计思想




                     Google Confidential and Proprietary   8
林顺 Sean Lin
Cocos2d-html5 核心开发者
Cocos2d-x核心开发者!




              Google Confidential and Proprietary   9
Cocos2d-html5简介


•    原生Javascript

•    兼容cocos2d-x API

•    兼容JS binding API

•    MIT license!




                        Google Confidential and Proprietary   10
Cocos2d-HTML5框架



                                            Games



             Cocos2D
                                                                                           Box2d
             Graphic                         Menu        CocosDenshion
                                                                                           Physics
                                                             Audio
    Canvas                 WebGL             DOM


                      PC                                    Mobile Phone


 Chrome      Safari    FireFox     ......       Chrome     Safari           ......               ......



                                                                    Google Confidential and Proprietary   11
引擎支持的图层结构




            Google Confidential and Proprietary   12
游戏的发布

                               HTML5&GAMES
     cocos2d&html5
For$HTML5,$Canvas$and$WebGL


                               COCOS2D&HTML5
cocos2d&js(binding
     Same%API,%Quick%Publish


  cocos2d&x(game(                                CANVAS
        resources
  Easy%Por)ng,%Low%cost




                                        Google Confidential and Proprietary   13
跨平台性能



                   iOS   Android   WP   Windows   OS X        Ubuntu           Browser



 cocos2d-iphone

cocos2d-android

  cocos2d-xna

   cocos2d-x

 2dx lua binding

 cocos2d-html5




                                                         Google Confidential and Proprietary   14
Write once, run anywhere


                        Games&Wri*en&in&JS

                                                               JavaScript
                             SAME&JS&API

               JS&API                      cocos2d4html5



  JS&Binding            cocos2d4?                     CANVAS




                                                               Google Confidential and Proprietary   15
Cocos2d-HTML5特性

•  -x,-iphone开发者的无缝过渡

•  cocos or cc 名字空间

•  使用、安装简单




                        Google Confidential and Proprietary   16
HelloWorld C++和JS代码对比




                        Google Confidential and Proprietary   17
代码对比

//C++

// add "HelloWorld" splash screen"

   CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png");

  pSprite->setPosition( ccp(size.width/2, size.height/2) );

//JS

// add "HelloWorld" splash screen”

var pSprite = cc.Sprite.spriteWithFile(“HelloWorld.png");

pSprite.setPosition( cc.ccp(size.width/2, size.height/2) );


                                                         Google Confidential and Proprietary   18
俄罗斯方块Demo




            Google Confidential and Proprietary   19
Layer的继承和鼠标消息的处理




                   Google Confidential and Proprietary   20
游戏的移植和开发

C++ API:                        JS API:

CCDirector                      cc.Director

CCDirector::sharedDirector();   cc.Director.sharedDirector();

CCDirector::sharedDirector()-   cc.Director.sharedDirector() .
  >getWinSize();                   getWinSize();

CCScene                         cc.Scene

CCLayer                         cc.Layer

CCSprite                        cc.Sprite



                                              Google Confidential and Proprietary   21
RoadMap




   Alpha    Beta   Chrome      Other   Mobile
                    Game     Browsers Browsers


                    2012

          DOM
Canvas              JS binding   WebGL
          Menu




                                      Google Confidential and Proprietary   22
Google Confidential and Proprietary   23

More Related Content

PDF
iOS Game Development with Cocos2D
PPTX
Using Tableau to Assess Electronic Resources in Context
PDF
Articulo Sindrome Nefrotico
PPTX
Stanford Law School Presentation on Innovations in Law Firm Model
PDF
Toan pt.de029.2011
PDF
Nutrition Coach
PDF
Komsomolskaya Pravda - «Комсомольская правда» "ТУРЕЦКОЕ СОЛНЦЕ В РОССИИ"
PPT
Morocco mgf - open data
iOS Game Development with Cocos2D
Using Tableau to Assess Electronic Resources in Context
Articulo Sindrome Nefrotico
Stanford Law School Presentation on Innovations in Law Firm Model
Toan pt.de029.2011
Nutrition Coach
Komsomolskaya Pravda - «Комсомольская правда» "ТУРЕЦКОЕ СОЛНЦЕ В РОССИИ"
Morocco mgf - open data

Viewers also liked (15)

PDF
Discurso del lehendakari - Visita al Hospital Alto Deba
PPT
Top 15 MySQL parameters
PDF
09 creating windows phone game with cocos2d-xna
PPTX
край де варто жити
PPTX
Enciclopedia de los diferentes comandos de personalizacion de diapositivas p...
PDF
PDF
Excellent Cities For Young Entrepreneurs in 2017 | Jerry Novack
PDF
Design of a novel controller to increase the frequency response of an aerospace
PDF
Article hotellerie
PPT
20101023 mind mapping
PDF
05 optimization of cocos2d-x games on x86 architecture
PPT
Sellick Partnership Legal Presentation
PDF
Los Seres Vivos
PPTX
Philosophy of history
Discurso del lehendakari - Visita al Hospital Alto Deba
Top 15 MySQL parameters
09 creating windows phone game with cocos2d-xna
край де варто жити
Enciclopedia de los diferentes comandos de personalizacion de diapositivas p...
Excellent Cities For Young Entrepreneurs in 2017 | Jerry Novack
Design of a novel controller to increase the frequency response of an aerospace
Article hotellerie
20101023 mind mapping
05 optimization of cocos2d-x games on x86 architecture
Sellick Partnership Legal Presentation
Los Seres Vivos
Philosophy of history
Ad

Similar to 06 html5 and cocos2d-x (20)

PDF
For cocos2d jpn devcon
PDF
OGDC 2014: Program farmery by cocos2dx
PDF
OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr...
PPTX
20151120 ian cocos2d js
PDF
Build a Game in 60 minutes
KEY
Cross Game Dev with Corona
PDF
02 evolution innovation and participation
PDF
Cocos最新情報(2015/4/27)
PPTX
ngGoBuilder and collaborative development between San Francisco and Tokyo
PPTX
Cocos2d for beginners
PPTX
Developing native cross platform games on Cocos2dx2
PDF
Targeting Android with Qt
PDF
Cocos2d-x C++ Windows 8 &Windows Phone 8
PDF
BCON22: oneAPI backend - Blender Cycles on Intel GPUs
PDF
Cross Platform Game Programming with Cocos2d-js
PDF
Developing for BlackBerry 10 – Tools and SDKs by Luca Filigheddu
PDF
Introduction to QtWebKit
PPTX
Introduction to BlackBerry 10 NDK for Game Developers.
PPTX
Introducing canvas gl (company100)
PPTX
CanvasGL, a GPU-accelerated WebKit
For cocos2d jpn devcon
OGDC 2014: Program farmery by cocos2dx
OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr...
20151120 ian cocos2d js
Build a Game in 60 minutes
Cross Game Dev with Corona
02 evolution innovation and participation
Cocos最新情報(2015/4/27)
ngGoBuilder and collaborative development between San Francisco and Tokyo
Cocos2d for beginners
Developing native cross platform games on Cocos2dx2
Targeting Android with Qt
Cocos2d-x C++ Windows 8 &Windows Phone 8
BCON22: oneAPI backend - Blender Cycles on Intel GPUs
Cross Platform Game Programming with Cocos2d-js
Developing for BlackBerry 10 – Tools and SDKs by Luca Filigheddu
Introduction to QtWebKit
Introduction to BlackBerry 10 NDK for Game Developers.
Introducing canvas gl (company100)
CanvasGL, a GPU-accelerated WebKit
Ad

More from 乐费 胡 (11)

PPTX
神仙道移动Ui演变
PDF
10 multi-platform game development using cocos2d-x
PDF
08 gaming framework design based on cocos2d-x
PDF
07 funny sango td and cocos2d-x
PDF
04 growing up with the open source community
PDF
03 crazy castle meets cocos2d-x
PDF
01 cocos2d past, present and future
PDF
11 share experience on porting 3 kingdoms td legned of shu
PPTX
Web并发模型粗浅探讨v3
PPT
Oauth tutorial
PPT
[.产品设计与用户体验(马化腾)
神仙道移动Ui演变
10 multi-platform game development using cocos2d-x
08 gaming framework design based on cocos2d-x
07 funny sango td and cocos2d-x
04 growing up with the open source community
03 crazy castle meets cocos2d-x
01 cocos2d past, present and future
11 share experience on porting 3 kingdoms td legned of shu
Web并发模型粗浅探讨v3
Oauth tutorial
[.产品设计与用户体验(马化腾)

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation theory and applications.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
Cloud computing and distributed systems.
PPT
Teaching material agriculture food technology
PPTX
Machine Learning_overview_presentation.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Empathic Computing: Creating Shared Understanding
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
A Presentation on Artificial Intelligence
Dropbox Q2 2025 Financial Results & Investor Presentation
Chapter 3 Spatial Domain Image Processing.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation theory and applications.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Cloud computing and distributed systems.
Teaching material agriculture food technology
Machine Learning_overview_presentation.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Reach Out and Touch Someone: Haptics and Empathic Computing
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Building Integrated photovoltaic BIPV_UPV.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Big Data Technologies - Introduction.pptx
Assigned Numbers - 2025 - Bluetooth® Document
Empathic Computing: Creating Shared Understanding
gpt5_lecture_notes_comprehensive_20250812015547.pdf

06 html5 and cocos2d-x