开发者

In cocos2d, is there something paralled to onEnter and onExit?

I can capture scene change events by its onEnter and onExit methods. But when scene change events takes time, like fade in or fade out, onEnter is called to early (right before the fading) and onExit is called to late (after the fading completed).

I want another onEnter called right after the fad开发者_如何学JAVAing completed and another onExit called right before the fading. Can i?


There's a second onEnter callback just for transitions, it's called onEnterTransitionDidFinish. But like it has been mentioned, this will only fire if CCScheduler is being used in conjunction with CCSceneTransition.


Use a CCSequence with your CCFadeIn and then add a CCCallFunc after it.

onEnter and onExit are to do with CCNode object allocation and removal, not physical views.

Sample code:

[scene runAction:[CCSequence actions:
   [CCFadeIn actionWithDuration:0.45f],
   [CCCallFunc actionWithTarget:scene selector:@selector(fakeOnEnter:)], nil]];

Inside your scene object you will need a method as such,

-(void) fakeOnEnter:(id)sender {
  // your code to run after the fadein
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜