0

所以我从主游戏类创建一个名为 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
 }
}

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

 -(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];
 }

 }
4

0 回答 0