Search code examples
iosxcodecocos2d-iphone

Assigning a number to a level in cocos2d


I want to make a method that adds a number to another number. This number will be assigned to the game level, and as the number goes up, the game gets harder. At the end of each level, I will play this method, and therefore the level number will go up. I know that this is really simple, I just can't seem to get my head around it, don't laugh!


Solution

  • so you want a method that will increase a ivar?

    @interface Game : NSObject {
        NSInteger level;
    }
    @property (readonly) NSInteger level;
    - (void)nextLevel;
    @end
    
    @implementation Game
    
    @synthesize level;
    - (void)nextLevel {
        level++;
    }
    @end