I have a method called addEnemy in my class called Enemy, and I want to call this method in another class called EnemyLayer. I would use [Enemy addEnemy];, but it’s not a static method (-(void)addEnemy). How can I do this?
I have a method called addEnemy in my class called Enemy, and I want
Share
You must first import the
Enemy.hfile into yourEnemyLayerfile. Then, create an instance of theEnemyclass in yourEnemyLayerfile. You can then call theaddEnemymethod on that instance:(in your example, you were trying to call the method on the entire
Enemyclass, but it’s not a class method, so you have to call it on an instance of that class.)