I want to do stuff in my scene when it is transitioned to. Is there anything in cocos2d similar to viewDidLoad that is called when I switch to a scene or layer? Thanks
Yes, in the scene subclass implementation add:
-(void) onEnter
{
[super onEnter];
// your code here
}
-(void) onEnterTransitionDidFinish
{
[super onEnterTransitionDidFinish];
// your code here
}
The first runs immediately after the scene was presented, and if the scene is presented with a transition, the latter will run after the transition completed.
Note that calling the super implementation is mandatory. Otherwise you may lose input/update or other functionality.