Took a bit of time off work to work on an update to the Rocket Attack game that I made for the iPhone. Here are a few screenshots of the newer version.


Took a bit of time off work to work on an update to the Rocket Attack game that I made for the iPhone. Here are a few screenshots of the newer version.


So, I’ve been learning some Objective-C to do my iPhone programming, and am gradually getting into the more interesting parts of it. Just now I’ve been playing with protocols to define some basic structures for my next iPhone game.
I guess you could say that a protocol is very similar to an interface class in c++, excepting that you can have optional methods as well as the required methods, allowing your classes to implement only the optional methods that you wish to use.
Here’s an example of a protocol definition
@protocol GameScreen@required -(id) init; -(void) draw; -(void) update:(float)time; @optional -(void) tapeventDragBegin:(CGPoint)origin; -(void) tapeventDrag:(CGPoint)origin currentPosition:(CGPoint)current; @end
Using the @required keyword indicates the methods that will be required for any class to define, while methods after the @optional keyword will not need to be implemented.
You can implement the protocol in a class by using the following code
@interface MainScreen : NSObject{ } // required methods -(id) init; -(void) draw; -(void) update:(float)time; // optional methods -(void) tapeventDrag:(CGPoint)origin currentPosition:(CGPoint)current; @end
There is one other thing that you will need to consider when coding to handle optional methods, and that is the problem of whether the method has actually been implemented or not. Fortunately, you can use the respondsToSelector method to check if it’s been implemented prior to calling it.
if([myScreen respondsToSelector:@selector(tapeventDrag:currentPosition:)]){
[myScreen tapeventDrag:origin currentPosition:current];
}
You may have noticed that it’s been a little quiet around here of late. The main reason for this is that I’ve gone and jumped on the bandwagon and got myself an iPhone. Then, to be able to write stuff for it, I went out and got a MacBook. Then, I found out that it needed to use a slightly different programming language (objective-c). So, after learning the required language, paying the ability to write software, and spending so much time.. I kind of felt the need to make good on my expense and write something to publish. So, I went and wrote a small game called Rocket Attack, which is now finished and up to be added to the iPhone AppStore
Rocket Attack
You are in command of an SA27-3 terrestrial defense station, and are responsible for the defense of eight major cities from orbital bombardment.

The SA27-3 defense station incorporates the following special features, which are unseen in earlier versions.
This concludes your briefing on the SA27-3, time to lock-and-load (pew-pew).