Reputation: 323
I have a spriteHandler object that composes (has) a CCSprite. It also composes a behavior object that 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?
Upvotes: 0
Views: 913
Reputation: 1455
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];
Upvotes: 2