
Untitled
By: a guest on
May 12th, 2012 | syntax:
None | size: 1.29 KB | hits: 19 | expires: Never
Accessing getter methods
#import "cocos2d.h"
#import "Box2D.h"
#import "GLES-Render.h"
#import <Foundation/Foundation.h>
@class UILayer;
@class Insect;
@interface GamePlayLayer : CCLayer {
b2World * world;
GLESDebugDraw * debugDraw;
CCSpriteBatchNode * sceneSpriteBatchNode;
Insect * insect;
b2Body *body;
SceneUILayer * uiLayer;
double startTime;
bool gameOver;
bool gameWon;
NSMutableArray *lives;
}
- (id)initWithUILayer:(UILayer *)sceneUILayer;
@end
UILayer * sr = (UILayer *)[self.parent getChildByTag:10];
CCSprite * live = [sr.lives objectAtIndex:self.lives];
[live setVisible:NO];
@interface UILayer : CCLayer {
NSMutableArray *lives;
}
@property (nonatomic,retain) NSMutableArray *lives;
#import "UILayer.h"
#import "GameManager.h"
@implementation UILayer
@synthesize lives;
- (id)init {
if ((self = [super init])) {
lives = [[NSMutableArray arrayWithCapacity:3]retain];
for(int i=0;i<3;i++)
{
CCSprite * life = [CCSprite spriteWithFile:@"life_Label.png"];
[life setPosition:ccp(winSize.width/18+ 32*i,290)];
[self addChild:life];
[lives addObject:life];
}
}
@interface blah
// ...
@property (assign) NSInteger lives;
@end
@implementation blah
@synthesize lives = _lives;
//your code
@end