Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17078

GetRunningScene() returns NULL... always!

$
0
0

@Lem wrote:

Hello!

I want to get my current running scene but I always get NULL, I have a scene and a NotificationNode above the scene. Can this be the problem?

Game2* gameScene = dynamic_cast<Game2*>(Director::getInstance()->getRunningScene());

I even desperately checked if maybe the type does not match (since then dynamic_cast returns NULL) so I checked other options like this:

Game2_Scene1Layer* test1 = dynamic_cast<Game2_Scene1Layer*>(Director::getInstance()->getRunningScene());
    Game2_Scene1* test2 = dynamic_cast<Game2_Scene1*>(Director::getInstance()->getRunningScene());
    ISceneLoader* test3 = dynamic_cast<ISceneLoader*>(Director::getInstance()->getRunningScene());

But here I also get NULL everywhere open_mouth Is there a way to get the type of the current running scene to I can cast it to the correct type? stuck_out_tongue

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 17078

Trending Articles