I have a spriteHandler object that composes (has) a CCSprite. It also composes a behavior object that开发者_JS百科 has a method -update:(ccTime)dt
, and a method -updateSelector
that returns @selector(update:)
. In the spriteHandler object, I want to use the method -schedule:(SEL)selector
, implemented by CCSprite. The call [sprite schedule:[behavior getUpdateSelector]]
fails; I can only figure out how to schedule something if you subclass CCNode. Is there any way to do this through composition?
Do you want to run something just once or every frame? what do you mean, it fails?
In case [sprite schedule:@selector(behaviourMethod)]
doesn't work try this instead:
[[CCScheduler sharedScheduler] scheduleSelector:@selector(behaviourMethod) forTarget:self interval:0.1 paused:NO];
精彩评论