Sunday, October 4, 2015

Snake Game Using Cocos2d-x Javascript iOS - PART 6

Now we come to the interesting part of this  tutorial series, we will take our game and compile it as iOS game .
For this Tutorial we need some prerequisites before we start .
  1. Mac. 
  2. iOS Device for testing . i strongly recommend to test the games on real device .
  3. Xcode 7, in this version you can test on your device without paying the 99$ .

1. We will use the same project we created in: Snake Game Using Cocos2d-x HTML5 - PART 1
Fill free to create the project again in your Mac and copy only the source files and the res directory.
The source files and the Xcode project files located in ( i create my projects in Projects directory) :
../cocos2d-x-3.8.1/Projects/SnakeJS/frameworks/runtime-src/proj.ios_mac/SnakeJS.xcodeproj


2. Click on SnakeJS.xcodeproj and if you installed Xcode 7 ( Remember 7 ...) it should load the project and you suppose to see this in Xcode :


3. Connect your iOS device into your MAC , Xcode should recognize it .
Then in Xcode go and set the active scheme to: SnakeJS-Mobile -> Your-IPhone-name




4. Lets hit "build" to see that every thing is fine by now ,  but before that we must set in Xcode :
  1. Set the deployment target to 7 and above in the General -> Deployment section.
  2. Also the current Cocos2d-x 8.1 have some kind of bug with bitecode set to Yes
    so lts change it to: No
    Go to Targets : SnakeJS->mobile then on the right screen
    Build Options ->Enable Bitcode = No
If you skip the above section Xcode will show you this error :
XCODE 7 and ENABLE_BITCODE=YES setting does not work

Now when all is set
Go to Product -> Build.
Wait few minutes , let the compilation to end .

5. If all went right you will see the game launching on your device and immediately start to play .
If you try to move it you will notice that none of the Touch controls are working
This is simply because in our code we don't have any touch handling .
We will write the code to handle this in next chapter .

We are ready to continue building our "SnakeJS" game for iOS Device in the next tutorial :
Snake Game Using Cocos2d-x Javascript iOS- PART 7

Play the final SnakeJS game :
http://meiry.github.io/SnakeJS-html5/publish/html5/
The SnakeJS source code:
https://github.com/meiry/SnakeJS-html5



No comments:

Post a Comment

Note: Only a member of this blog may post a comment.