23
Google Confidential and Proprietary 胡坤 Google Chrome/HTML5 开发技术推广经理 林顺 Cocos2d-html5 核心开发者 Cocos2d-x & HTML5 1

06 html5 and cocos2d-x

  • Upload
    -

  • View
    687

  • Download
    4

Embed Size (px)

DESCRIPTION

kun hu (google) and shun lin

Citation preview

Page 1: 06   html5 and cocos2d-x

Google Confidential and Proprietary

胡坤 Google Chrome/HTML5 开发技术推广经理 林顺 Cocos2d-html5 核心开发者

Cocos2d-x & HTML5

1

Page 2: 06   html5 and cocos2d-x

Google Confidential and Proprietary

HTML5游戏引擎 之 资源加载

2

Page 3: 06   html5 and cocos2d-x

Google Confidential and Proprietary

Cocos2d-HTML5的设计思想

3

Page 4: 06   html5 and cocos2d-x

Google Confidential and Proprietary

HTML5游戏引擎 之 性能

•  Update & Draw

•  > 60帧 = Kill Browser

•  Inner Timer à Fixed Tick

•  Canvas in Canvas

4

Page 5: 06   html5 and cocos2d-x

Google Confidential and Proprietary

Cocos2d-HTML5 内部时钟

内部时钟的实现,保证固定的步长

5

t0 tt1 t2

S =S0+ t *v;

Loop1 Loop2 Loop3 Loop n

Page 6: 06   html5 and cocos2d-x

Google Confidential and Proprietary

HTML5游戏引擎 之 兼容性

6

Page 7: 06   html5 and cocos2d-x

Google Confidential and Proprietary

Cocos2d-HTML5的设计思想

7

Page 8: 06   html5 and cocos2d-x

Google Confidential and Proprietary

Cocos2d-HTML5的设计思想

8

Page 9: 06   html5 and cocos2d-x

Google Confidential and Proprietary 9

林顺 Sean Lin Cocos2d-html5 核心开发者 Cocos2d-x核心开发者!

Page 10: 06   html5 and cocos2d-x

Google Confidential and Proprietary

Cocos2d-html5简介

•  原生Javascript

•  兼容cocos2d-x API

•  兼容JS binding API

•  MIT license!

10

Page 11: 06   html5 and cocos2d-x

Google Confidential and Proprietary

Cocos2d-HTML5框架

Cocos2DGraphic

Canvas WebGL

CocosDenshionAudio

Box2dPhysics

Games

PC

Chrome Safari FireFox ......

Mobile Phone

Chrome Safari ...... ......

Menu

DOM

11

Page 12: 06   html5 and cocos2d-x

Google Confidential and Proprietary

引擎支持的图层结构

12

Page 13: 06   html5 and cocos2d-x

Google Confidential and Proprietary

游戏的发布

13

COCOS2D&HTML5

CANVAS

HTML5&GAMES

For$HTML5,$Canvas$and$WebGL

cocos2d&html5

Same%API,%Quick%Publish

cocos2d&js(binding

cocos2d&x(game(resources

Easy%Por)ng,%Low%cost

Page 14: 06   html5 and cocos2d-x

Google Confidential and Proprietary

跨平台性能

iOS

cocos2d-iphone

cocos2d-x

cocos2d-android

Android WP BrowserWindows Ubuntu

2dx lua binding

OS X

cocos2d-html5

cocos2d-xna

14

Page 15: 06   html5 and cocos2d-x

Google Confidential and Proprietary

Write once, run anywhere

Games&Wri*en&in&JS

JS&Binding cocos2d4?

JS&API

SAME&JS&API

cocos2d4html5

CANVAS

15

JavaScript������

Page 16: 06   html5 and cocos2d-x

Google Confidential and Proprietary

Cocos2d-HTML5特性

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

•  cocos or cc 名字空间

•  使用、安装简单

16

Page 17: 06   html5 and cocos2d-x

Google Confidential and Proprietary

HelloWorld C++和JS代码对比

17

Page 18: 06   html5 and cocos2d-x

Google Confidential and Proprietary

代码对比

//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) );

18

Page 19: 06   html5 and cocos2d-x

Google Confidential and Proprietary

俄罗斯方块Demo

19

Page 20: 06   html5 and cocos2d-x

Google Confidential and Proprietary

Layer的继承和鼠标消息的处理

20

Page 21: 06   html5 and cocos2d-x

Google Confidential and Proprietary

游戏的移植和开发

C++ API:

CCDirector

CCDirector::sharedDirector();

CCDirector::sharedDirector()->getWinSize();

CCScene

CCLayer

CCSprite

21

JS API:

cc.Director

cc.Director.sharedDirector();

cc.Director.sharedDirector() .getWinSize();

cc.Scene

cc.Layer

cc.Sprite

Page 22: 06   html5 and cocos2d-x

Google Confidential and Proprietary

RoadMap

Alpha Beta

DOMMenu

ChromeGame

Canvas WebGLJS binding

Other Browsers

Mobile Browsers

2012

22

Page 23: 06   html5 and cocos2d-x

Google Confidential and Proprietary 23