ogdc 2014_hands on experience with cocos2dx in cross-platform with farmery_mr. vu ngoc kien
TRANSCRIPT
Farmery development using
cocos2d-x
Vu Ngoc Kien - Game Studio North / VNG
Farmery Game
Farmery Game
Over 1M downloads on Google Play
Top 10 frees on Apple Store
Run well on low specs as Galaxy Y phone
Coming soon on WP
Cocos2d-x - Cross platform game engine
2D Cross-Platform engine game
Open source
High performance
Using cocos2d-ios documents as APIs are
similar
Many support tools
Advantages
Not easy
Many choices: C++, Lua, Java Script
Use C++ language
Require understandings of different
platforms setup
Approach Cocos2d-x
1. Animation in Farmery game
2. Multiscreen in Cocos2d-x
3. Debug Cocos2d-x on Android
Farmery development using Cocos2d-x
Over 125 animations in game
Optimize to save memory
1. Animation in Farmery
Frame-By-Frame Animation
64 pictures, 2MB
Tween Animation
5 pictures, 240 KB
Make Animations using Dragon Bone
http://dragonbones.github.io
Artists produce objects parts
Assemble animations on Flash
Extract animation file using Dragon Bone
Result
Using flash in animation
Import PSD Layer
Support pictures skewing
Advantages
1. Animation in Farmery game
2. Multi screen in Cocos2d-x
3. Debug Cocos2d-x on Android
Farmery development using Cocos2d-x
2. Multi screen in Cocos2d-x
480 x 320
2048 x 1536
1136 x 640
1080 x 1920
DesignResolutionSize: standard screen size
CCEGLView::sharedOpenGLView()->setDesignResolutionSize
(width, height, policy)
Policy:
• Exact fit
• Show all
• No border
• Fixed Height
• Fixed Width
Multiscreen in cocos2d-x
Picture looks stretched
Exact fit
2 black edges on the screen
Show all
No border
contentScaleFactor = RH/DH, resource for screen suitably
contentScaleFactor = (RH/DH)/ (MIN(fScaleX, fScaleY) /
MAX(fScaleX, fScaleY)).
fScaleX = FW/ DW; float fScaleY = FH/DH.
contentScaleFactor
Farmery displays well on different screen sizes
1. Animation in Farmery game
2. Multiscreen by Cocos2d-x
3. Debug Cocos2d-x on Android
Farmery development using Cocos2d-x
Require Cygwin, NDK
Setup NDK path
Can’t debug native
Build cocos2d-x on Android by Cygwin on Windows
Build cocos2d-x on Android by eclipse
Not require Cygwin
Can debug native
Undefined Cygwin
(properties -> C/C++ Build -> Environment)
Edit Project Properties
Use Android GCC tool chain
(properties -> C/C++ Build -> Tool Chain Editor)
Edit Project Properties
• Setting build command: ndk-build NDK_DEBUG=1 –j8
(properties -> C/C++ Build -> Builder Setting)
Edit Project Properties
Link Classes folder
(properties -> C/C++ General -> Paths and Symbols -> Source Location)
Edit Project Properties
Add module path
$(call import-add-path,(LOCAL_PATH)/../../../../../)
$(call import-add-path,(LOCAL_PATH)/../../../../../cocos2dx/platform/third_party/android/prebuilt)
$(call import-module,cocos2dx)
Edit file Android.mk
Crash will show on LogCat
Use Breakpoint to debug
1. Make Animation with Flash and Dragon Bone
2. Multiscreen by Cocos2d-x
3. Debug cocos2d-x on Android by Eclipse
Develop Farmery by Cocos2d-x
Farmery development using cocos2d-x
Vu Ngoc Kien [email protected] (Game Studio North /VNG)