嗨,大家好,請誰能幫了這個錯誤:「訪問未知的生活的getter方法」我下面的代碼獲得一,二號線(CCSprite線)。訪問getter方法
GamePlayLayer.h是:
#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
GamePlayLayer.m
UILayer * sr = (UILayer *)[self.parent getChildByTag:10];
CCSprite * live = [sr.lives objectAtIndex:self.lives];
[live setVisible:NO];
奧萊特我不得不添加以下信息:
的UILayer.h(該UILayer是HUD層)文件是:
@interface UILayer : CCLayer {
NSMutableArray *lives;
}
@property (nonatomic,retain) NSMutableArray *lives;
的UILayer.m是:
#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];
}
}
你應該在你聲明這個生命財產的地方包含你的頭像,'自我'在這裏。什麼是UILayer? – 2011-12-22 22:32:03
@Firoze Lafeer我已添加更多代碼,希望其更清晰 – Zaki 2011-12-22 23:31:15
GamePlayLayer.h呢? – 2011-12-23 00:23:35