30
Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Embed Size (px)

Citation preview

Page 1: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Extending Cocos2D-xMobile 2D Framework

Rony XuHappy Elements

Page 2: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Agenda

Why

Overall Framework Design

Q&A guide

Page 3: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Why we use Cocos2Dx?

Page 4: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Techniques We Used

Cocos2d-iphone

HTML5

Adobe Air Porting

Cocos2Dx

Conora

Unity

Cross-platform

Controllability

Performance

Page 5: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Why scripting?

Page 6: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Multi-version

IOS/some Android mkts can’t incremental update

Big pack with all resolution, wasting bandwidth and

storage.

Update issues

Google Play : 2

hours

IOS : 5 days

Update CycleUpdate Cycle

Page 7: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Different Develop & Debugging tools

Context broken

Difficulties on device debugging

Debug Issues

1. Need script for compile, deploy & debug2. NDK in Eclipse is very difficult to debug

Need to use MAC for compile, deploy &

debug

IOSIOS

AndroidAndroid

Page 8: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

50% of the debugging time is dealing with

crash

Easy Crash : using Auto-Release Pool

Easy to Lose Context/Stack, especially in

optimized mode

Crash

Quality standard5% crash rate over

5000 minutes testing

sessions

Page 9: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Why we choose Lua?

Page 10: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Easy, Controllable

Lightweight

Most games in China market is written

with cocos2dx+lua

Solutions

Page 11: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

What have we done?

Page 12: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Android : Java Lua

IOS: OC Lua

LuaJit replace Lua 5.1

3rd party Lib API

Page 13: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

IDE & Debugger

UI Editor

Animation Editor

TTF Font export tools

Tools

Page 14: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

COCOS2D-X

Develop Tools

Mem Disambiguation

Mem Disambiguation

Localization

Localization

UtilitiesUtilities NetworkNetwork

Resource Management

Resource Management

CrashCrash

Render

Render

Script EngineScript Engine

Third party Integration

AccountAccount SNS Integration

SNS Integration

PaymentPayment NotificationNotification

Data Analytics

Data Analytics

Ad/x-promAd/x-prom

Log TrackerLog Tracker CI ServiceCI Service

IDEIDE

Automated Build ScriptsAutomated Build Scripts

Debugger

Debugger

PackagingToolsPackagingToolsLoggerLogger

Engine

Page 15: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Lua scripting runtimeLua scripting runtime

toLua++toLua++

Cocos2dx/Cocos2dx/Common LibCommon Lib iOS native apiiOS native api

LuaJavaLuaJava

iOS 3rd party iOS 3rd party APIAPI

Android 3rd Android 3rd party APIparty API

Android Android native APInative API

Interface w/ languages

WaxWax

Page 16: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

- Base on Zerobrane

- Enhance 120x debugging performance

- Locating files & symbols

- Push to device

- Improve context helper

Lua debugger

Page 17: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

StubStub

DebuggerDebugger

iOS stubiOS stubiOS stubiOS stub

Android Android stubstub

Android Android stubstub

Windows Windows stubstub

Windows Windows stubstub

File List & MD5

Connect Debugger

Connection Success

Log & Breakpoint

Changed File

File Push

Close connection

Send Instruction

File Deploy Process Debug Process

Push to device

Page 18: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

• Complete the Update transaction

• Increment update

• Download on Demonds

• Modules

• Resolutions

• Resources Encryption

• APK Update (China Android Markets)

Resource Manager – Design Purpose

Page 19: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

APK/App Directory

Resource Manager - Design

Current Current Resource Resource LocatorLocator

Resource Resource Locator Locator versionversion

Content with md5 name

Old Resource Old Resource LocatorLocator

Document Directory

Content with md5 name

Content with md5 name

Page 20: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

ClientClient CDNCDN

Dynamic Dynamic ServerServer

Get the latest configuration

Download configuration

Download ResourcesCheck if the current

configuration up-to-date

Check the missing resource

Incremental update

Page 21: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

ClientClient

CDNCDNGameGameGameGame

Res Res MgrMgrRes Res MgrMgr

Ensure Modules

Local cache ?

Download Resource

Callback Result

Download on Demand

Load Resource

Page 22: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Crash analyze system

PLCrash PLCrash reporterreporterPLCrash PLCrash reporterreporter

GoogleGooglebreakpadbreakpadGoogleGoogle

breakpadbreakpad Crash Crash AnalysisAnalysisCenterCenter

Crash Crash AnalysisAnalysisCenterCenter

Log trackerLog trackerLog trackerLog tracker

Game

Crash folder

Crash Sent Crash Sent TaskTask

Crash Sent Crash Sent TaskTask

Developer

SymbolSymbolCenterCenterSymbolSymbolCenterCenter

Build

Page 23: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

- Hudson

- Download & install on mobile

- Update notice, auto-download update package

- Crash/ Log collect & analyze

- Session time analyze

- CDN check

- Udid management

- Oneclick submit to App store & Google Play (future)

Build/CI

Page 24: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Build/CI

Build.shBuild.sh

symbolssymbols

HudsonHudson

apk/ipa/png

apk/ipa/png

resources

resources

Adhoc.mobileprovisionAdhoc.mobileprovision

SvnSvn

build_versionbuild_version

Project.plistProject.plist

SafariSafariMobile BrowserMobile

Browser

Udid CheckUdid Check Resource Manager

CDN

Resource Manager

CDN

CrashAnalysisCrash

Analysis

Latest VersionLatest

Version

Client Manager

Client Manager

Page 25: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Dragon Bones

■ Flash CS5.5+Plugin

■ UI Editor

■ Animation Editor

Font editor

■ BMP Font

■ TTF

Tools

Page 26: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Particle designer

Glyph designer

Third Party Tools

Page 27: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Thanks! OpenSource Community

Cocos2dxhttps://github.com/cocos2d/cocos2d-x

LuaJavahttp://www.keplerproject.org/luajava/

Waxhttps://github.com/probablycorey/wax

Page 28: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

ZeroBrane

https://github.com/pkulchenko/ZeroBraneStudio

Mobdebug https://github.com/pkulchenko/MobDebug

DragonBones

http://dragonbones.github.com

Thanks! OpenSource Community

Page 29: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements

Questions go to

• Name: Cong Ling• Email: [email protected]• WeChat: cong_ling1

Page 30: Extending Cocos2D-x Mobile 2D Framework Rony Xu Happy Elements