AnthonyJoeseph
AnthonyJoeseph

Reputation: 323

Compostion of -schedule:(SEL)selector in Cocos2d

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

Answers (1)

csch
csch

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

Related Questions