-
Book Overview & Buying
-
Table Of Contents
Cocos2d Cross-Platform Game Development Cookbook - Second Edition - Second Edition
By :
We will port the Swift project we created in the last chapter to Android.
The process of creating the project in SpriteBuilder is the same as in Swift; however, obviously, this time, the code needs to be in Objective-C.
Once the project is created in SpriteBuilder, we can open the project in Xcode 6.1.1 and even run the project to make sure there are no build errors.
The built project should run on our device as shown in the following screenshot:

Now, as in the Swift project, we have to create a Rocket class. So, we create a new class called Rocket. The Rocket.h and Rocket.m files should look similar to the following:
//Rocket.h
#import "CCSprite.h"
@interface Rocket : CCSprite{
CGSize winSize;
}
@endThe Rocket.m file should be as follows. Note that how we position the rocket is different here as compared to Swift:
#import "Rocket.h"
@implementation Rocket:CCSprite
-(void) didLoadFromCCB {
NSLog(@"%@ did load", self);
winSize = [[CCDirector...
Change the font size
Change margin width
Change background colour