开发者

cocos2d schedule selector error

开发者 https://www.devze.com 2023-03-11 02:36 出处:网络
i have an error when scheduling a method. (to display how many star you get according to your score. i have addStar0 addStar1 addStar2 addStar3 methods)

i have an error when scheduling a method. (to display how many star you get according to your score. i have addStar0 addStar1 addStar2 addStar3 methods)

[self schedule:@selector(addStar0) interval:0.2f];

and the methods are:

-(void) addstar0 {
    [self unschedule:_cmd];

    if (star > starProgress) {
        starProgress++;
        [self schedule:@selector(addStar1) interval:0.5f];
    }
    else {
        [self schedule:@selector(displayResult) interval:0.5f];
  开发者_开发知识库  }

}

error message:

Signature not found for selector - does it have the following form? -(void) name: (ccTime) dt

I've tried changing all my methods into addStar1: (ccTime) delta and schedule: @selector(addStar:) interval: 0.2f, but still the same. (actually i've used both ways to schedule( with/without parameter), and both of them worked well in my last project. )

also, one weird thing: sometimes i can't use [self schedule: something], but [CCScheduler sharedScheduler] schedule: something] works fine. I guess it may be project settings or so?

Please answer it with code. thank you.


You are using 'addStar0' for selector

[self schedule:@selector(addStar0) interval:0.2f];

then

-(void) addstar0 {

should be

-(void) addStar0 {


I think your error is actually on [self unschedule:_cmd];

Where is _cmd defined? Try commenting out that line and running it again.


put [self unschedule:_cmd]; after the else statement

0

精彩评论

暂无评论...
验证码 换一张
取 消