【发布时间】:2010-10-28 01:35:08
【问题描述】:
我正在使用两个调用 setScore,它们在 init 方法中进行,而在对象被销毁时使用 UpdateScore。当我运行程序时,只要调用 UpdateScore,我就会崩溃。有人看到我的代码有错误吗?非常感谢。
在我的 .h 文件中,我有 CCLabel *score;和 NSString *文本;声明供全球使用。
-(void)setScore{
scorE = 1;
text = [[NSString alloc] initWithFormat:@"%d", scorE];
score = [CCLabel labelWithString:text fontName:@"Marker Felt" fontSize:18];
score.position = ccp(45, 310);
[self addChild: score];
}
-(void)UpdateScore{
scorE++;
NSLog(@"score +1");
[score setString: [NSString stringWithFormat:@"%d",scorE]];
}
【问题讨论】:
-
崩溃时的错误信息是什么?
-
节目接收信号:“EXC_BAD_ACCESS”。
标签: iphone cocos2d-iphone