CCRepeatForever给了我EXC_BAD ACCESS

时间:2012-07-03 19:07:56

标签: ios cocos2d-iphone exc-bad-access

所以我正在从主游戏类创建一个名为Enemy的对象 敌人的对象是在ccmoveto上调用ccrepeatforever 我保留了移动并重复但仍然崩溃

这是一些代码

for (Enemy *iceLord in self.children) {
if ([iceLord isKindOfClass:[Enemy class]] && iceLord.isIceLord==YES) { <-----this is where     EXC_BAD_ACCESS is showing up

//DO Stuff
 }
}

//在敌人类里面我有这个方法我认为这是导致崩溃但我不明白为什么

 -(void)startWiggle{

int randomX = (arc4random()%30)+15;
int randomY = (arc4random()%40)+15;
int dieroll = arc4random()%2+1;
if (dieroll==1) {
randomY=randomY* -1;
}
if (self.position.y < winSize.height && self.position.y >0) {
id move = [CCMoveBy actionWithDuration:1 position:CGPointMake(-randomX, randomY)];

id forever = [CCRepeatForever actionWithAction:move];

 [self runAction:forever];
 [move retain];
 [forever retain];
 }

 }

0 个答案:

没有答案