Is there an event or method that a CCScene or CCLayer receives when it becomes active?
My situation is this:
called “replaceScene()” with SceneA, now SceneA is active / foreground.
called “pushScene()” with SceneB, now SceneB is active / foreground (and SceneA is hidden)
called “popScene()” within SceneB, now SceneB closes and SceneA becomes active again
QUESTION: Is there a way for SceneA to know it is back to the front of the scene stack and take action?
Try *onEnter()*
// SceneA.h
class SceneA : public cocos2d::CCLayer {
private:
// Members
public:
// Other methods
virtual void onEnter();
}
// SceneA.cpp
void SceneA::onEnter() {
// onEnter() is called everytime the layer is on screen.
// You can also use onEnterTransitionDidFinish()
CCLOG( "SceneA: Oh hey, I'm on stage!" );
}
Thank you very much for the response.
I ended up using
virtual void onEnterTransitionDidFinish();
That seems to work with CocosBuilder CCLayers.
I might be missing something with onEnter();
because it gave me trouble.
Is there some minimum amount of setup I should do in onEnter() like turn on touch?
The issue I had with onEnter was that it was called but the CocosBuilder didn’t work correctly with the onEnter() method in place.
Thanks again, working very nicely.