Extending CCSprite
Dr. Nicholas Fringe's enemies are an army of UFOs controlled by very intelligent extraterrestrial beings trying to wipe out all of mankind. That's why we're going to create them as a separate class that will derive from CCSprite
, where we will define its evolved behavior.
Some developers prefer to derive this kind of class from CCNode
and include a CCSprite
instance as it offers more potential, but for the moment we are going to keep it simple and just extend CCSprite
.
First of all, let's create the new class:
- Right-click on the Classes group in the project navigator and select New File….
- Click on iOS | cocos2d v3.x and choose to create the new file from the
CCNode
class template. - Type
CCSprite
in the available field and click on Next. - Call the file as
UFO
and be sure that the Classes folder is selected before clicking on Create.
Then replace the contents of UFO.h
with the following block of code:
#import <Foundation/Foundation.h> #import "...