-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Sparrow iOS Game Framework Beginner's Guide
By :
To structure the code of our ship, follow these steps:
Add a new group called Entities.
Inside this group, add a new Objective-C class called Ship, which is derived from SPSprite.
Open the Ship.h file. Add one instance variable for the ship image and another for the movie clip of the ship shooting cannonballs, as shown in the following code:
SPMovieClip *_shootingClip; SPImage *_idleImage;
Declare an alternative initializer called initWithContentsOfFile, which takes an NSString as its parameter:
-(id)initWithContentsOfFile:(NSString *)filename;
Declare a method called shoot, as shown in the following code:
-(void) shoot;
Declare another method called moveTo that takes the x value as its first parameter and the y value as its second parameter, as shown in the following code:
-(void) moveToX:(float) x andY:(float) y;
Declare a method called stop, as shown in the following code:
-(void) stop;
Define the default initializer for the Ship class with the following lines...
Change the font size
Change margin width
Change background colour