我希望将我的两个敌人设置为攻击模式,但是因为它只有最后一个添加的敌人被设置为攻击模式。
有没有办法解决?任何提示或建议表示赞赏。如果您需要更多代码,请告诉我。
-(void)ViewDidLoad {
for (_enemyPoint in [self.enemyGroup objects]) {
self.enemy = [[CCSprite alloc] initWithFile:@"Icon.png"];
self.enemy.scale = 32.0f/57.0f;
self.enemy.position = CGPointMake([_enemyPoint[@"x"] integerValue], [_enemyPoint[@"y"] integerValue]);
[self addChild:self.enemy];
}
self.pathfinder = [HUMAStarPathfinder pathfinderWithTileMapSize:self.tileMap.mapSize
tileSize:self.tileMap.tileSize
delegate:self];
[self enemyAttack];
}
- (void)enemyAttack{
self.epath = [self.pathfinder findPathFromStart:self.enemy.position
toTarget:self.player.position];
self.eactions = [NSMutableArray array];
for (_epointValueInPath in self.epath) {
self.epoint = _epointValueInPath.CGPointValue;
self.emoveTo = [CCMoveTo actionWithDuration:1.0f position:self.epoint];
[self.eactions addObject:self.emoveTo];
}
self.esequence = [CCSequence actionWithArray:self.eactions];
[self.enemy runAction:self.esequence];
}