Reputation: 149
I made a 'move' method for my enemy to move. The thing is that I have multiple different types of enemies, so I want them all to move relatively the same way. The only difference is the CCSpriteBatchNode, meaning the graphics are different. Is there a way to have the same move method, except modified a bit for each enemy type? Or is the only solution to copy and paste the method to each class and modify it there?
Upvotes: 0
Views: 95
Reputation: 21893
All your enemies should be a subclass of an "Enemy" base class. Implement the "move" function once, in the parent class, and then all the enemy subclasses will move the same way.
Upvotes: 1
Reputation: 5774
If you are using an object oriented approach you can do this with inheritance and virtual functions. I guess objective C support this kind of programming.
Upvotes: 0