开发者

Compostion of -schedule:(SEL)selector in Cocos2d

开发者 https://www.devze.com 2023-02-11 12:15 出处:网络
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(

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];
0

精彩评论

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

关注公众号