OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien
Transcript of OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien
![Page 1: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/1.jpg)
Farmery development using
cocos2d-x
Vu Ngoc Kien - Game Studio North / VNG
![Page 2: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/2.jpg)
Farmery Game
![Page 3: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/3.jpg)
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
![Page 4: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/4.jpg)
Cocos2d-x - Cross platform game engine
![Page 5: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/5.jpg)
2D Cross-Platform engine game
Open source
High performance
Using cocos2d-ios documents as APIs are
similar
Many support tools
Advantages
![Page 6: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/6.jpg)
Not easy
Many choices: C++, Lua, Java Script
Use C++ language
Require understandings of different
platforms setup
Approach Cocos2d-x
![Page 7: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/7.jpg)
1. Animation in Farmery game
2. Multiscreen in Cocos2d-x
3. Debug Cocos2d-x on Android
Farmery development using Cocos2d-x
![Page 8: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/8.jpg)
Over 125 animations in game
Optimize to save memory
1. Animation in Farmery
![Page 9: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/9.jpg)
Frame-By-Frame Animation
64 pictures, 2MB
![Page 10: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/10.jpg)
Tween Animation
5 pictures, 240 KB
![Page 11: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/11.jpg)
Make Animations using Dragon Bone
http://dragonbones.github.io
![Page 12: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/12.jpg)
Artists produce objects parts
![Page 13: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/13.jpg)
Assemble animations on Flash
![Page 14: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/14.jpg)
Extract animation file using Dragon Bone
![Page 15: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/15.jpg)
Result
![Page 16: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/16.jpg)
Using flash in animation
Import PSD Layer
Support pictures skewing
Advantages
![Page 17: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/17.jpg)
1. Animation in Farmery game
2. Multi screen in Cocos2d-x
3. Debug Cocos2d-x on Android
Farmery development using Cocos2d-x
![Page 18: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/18.jpg)
2. Multi screen in Cocos2d-x
480 x 320
2048 x 1536
1136 x 640
1080 x 1920
![Page 19: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/19.jpg)
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
![Page 20: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/20.jpg)
Picture looks stretched
Exact fit
![Page 21: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/21.jpg)
2 black edges on the screen
Show all
![Page 22: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/22.jpg)
No border
![Page 23: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/23.jpg)
contentScaleFactor = RH/DH, resource for screen suitably
contentScaleFactor = (RH/DH)/ (MIN(fScaleX, fScaleY) /
MAX(fScaleX, fScaleY)).
fScaleX = FW/ DW; float fScaleY = FH/DH.
contentScaleFactor
![Page 24: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/24.jpg)
Farmery displays well on different screen sizes
![Page 25: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/25.jpg)
1. Animation in Farmery game
2. Multiscreen by Cocos2d-x
3. Debug Cocos2d-x on Android
Farmery development using Cocos2d-x
![Page 26: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/26.jpg)
Require Cygwin, NDK
Setup NDK path
Can’t debug native
Build cocos2d-x on Android by Cygwin on Windows
![Page 27: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/27.jpg)
Build cocos2d-x on Android by eclipse
Not require Cygwin
Can debug native
![Page 28: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/28.jpg)
Undefined Cygwin
(properties -> C/C++ Build -> Environment)
Edit Project Properties
![Page 29: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/29.jpg)
Use Android GCC tool chain
(properties -> C/C++ Build -> Tool Chain Editor)
Edit Project Properties
![Page 30: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/30.jpg)
• Setting build command: ndk-build NDK_DEBUG=1 –j8
(properties -> C/C++ Build -> Builder Setting)
Edit Project Properties
![Page 31: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/31.jpg)
Link Classes folder
(properties -> C/C++ General -> Paths and Symbols -> Source Location)
Edit Project Properties
![Page 32: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/32.jpg)
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
![Page 33: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/33.jpg)
Crash will show on LogCat
![Page 34: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/34.jpg)
Use Breakpoint to debug
![Page 35: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/35.jpg)
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
![Page 36: OGDC 2014_Hands on experience with Cocos2dx in cross-platform with Farmery_Mr. Vu Ngoc Kien](https://reader031.fdocuments.in/reader031/viewer/2022020217/55529fcdb4c9051f108b546d/html5/thumbnails/36.jpg)