0
在触摸事件中,我正在获取EXC BAD ACCESS错误。被突出显示的行是:触摸事件中的EXC BAD ACCESS错误
如果([aCrate isKindOfClass:[木箱类]]){
im使用的cocos2d在ARC启用项目。我不知道为什么这个错误发生,并可以使用一些帮助调试。
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if ([[AppData sharedData]isGamePaused] == NO) {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
for (Crate* aCrate in self.children) {
if ([aCrate isKindOfClass:[Crate class]]) {
if ([self collisionWithPoint:location andRadius:40 andPoint:aCrate.crateSprite.position andRadius:aCrate.crateSprite.contentSize.width/2] && [aCrate isDestroyed] == NO) {
CGPoint crateLocation = aCrate.crateSprite.position;
[self crateTouched:crateLocation];
ScoreNode* aScore = [ScoreNode createWithScore:[[objectDict objectForKey:@"CrateHit"]integerValue]];
aScore.position = aCrate.crateSprite.position;
[self addChild:aScore z:zScoreNode];
[aCrate destroyed];
score = score + 50;
}
}
}
}
}
林将箱子对象与此代码和它没有任何地方删除
Crate* aCrate = [Crate createWithDictionary:crateDict];
[self addChild:aCrate z:zCrate];
它快把我逼疯了,所以任何帮助将是巨大的