Ricardo Cerqueira
Ricardo Cerqueira

Reputation: 69

Cocos2d Selector with multiple args

Lets say i wanna call a cocos2d method after 2 seconds, like this:

[self runAction:[CCSequence actions:
                     [CCDelayTime actionWithDuration:2],
                     [CCCallFunc actionWithTarget:[GameScene sharedScene] selector:@selector(GameOverAndLost:) withObject:TRUE],
                     nil]];

i'm trying to send a BOOL to that method, but somehow that doesn't seam to be the way

- (void) GameOverAndLost:(BOOL)bol

Anyone know's what i'm doing wrong here? this is quite a simple task, but i'm really not that used to ObjC

Upvotes: 0

Views: 253

Answers (1)

Guru
Guru

Reputation: 22042

One mistake in your code: Used CCCallFunc instead of CCCallFuncN. (CCCallFunc not takes any argument).

        [CCCallFuncN actionWithTarget:self selector:@selector(GameOverAndLost:)];

To send multiple argument, better go for CCCalBlockN.

id calFun = [CCCallBlockN actionWithBlock:^(CCNode* node) 
    {
        //control comes here when block is executed...
        //here you can access class member variables and variables in same function
    }
    ];

Upvotes: 3

Related Questions