Hello, I have a problem with selector.
I am trying to make an array of objects moving in a sequence.
Therefore, I wrote this code:
-(void)arrayEnemy{
CGSize size = [[CCDirector sharedDirector] winSize];
int r = arc4random() % 200;
spriteArray =[[NSMutableArray alloc]init];
for (i =1; i<7;i++ ) {
enemy = [[Enemy alloc] initWithFile:@"Icon-Small.png"];
[enemy setPosition:ccp(size.width /r, size.height /2)];
[self addChild:enemy];
enemy.tag = 1;
[spriteArray addObject:enemy];
}
}
-(void)something{
CGSize size = [[CCDirector sharedDirector] winSize];
[CCMoveBy actionWithDuration:2 position:ccp(size.width/2,0)];
}
-(void)follow{
[CCFollow actionWithTarget:[spriteArray objectAtIndex:0] worldBoundary:CGRectMake(3, 4, 2, 3)];
CCLOG(@"HEEE");
}
-(void)animation{
id moveAction = [CCCallFunc actionWithTarget:[spriteArray objectAtIndex:0] selector:@selector(something)];
id b = [CCCallFunc actionWithTarget:[spriteArray objectAtIndex:1] selector:@selector(follow)];
id c = [CCDelayTime actionWithDuration:3];
[self runAction:[CCSpawn actions:moveAction, c, b, nil]];
}
When I run it, the app stops and in the line: [targetCallback_ performSelector:selector_]; there is a SIGABRT signal.
I'm pretty sure this is something to do with the selector because I retyped so selector wouldn't be called and it worked.
However, I need selector because I need to make actionWithTarget.
I spent hours and hours to fix this problem and went through cocos2d document and reference, but I couldn't fix my problem.
Help me please.
Thanks.