Director::getInstance()->getRunningScene() is null

Try to get access to running scene seems to be not possible. I need it to add some sprites on the scene SpriteBatch and I don’t want to pass a reference of the Director for every class I make. How can I accomplish it outside the current scene class?

Director::getInstance()->getRunningScene() should work might be a bug, which version of the engine are you using?

Cocos2d-x 3.7.1 - MacOSX

I’m calling this function inside a class that is called on init() function from GameScene (or HelloWorld) intro class.

Director:: runWithScene will initialize the running scene.

If you’re calling Director::getInstance()->getRunningScene() before there is a running scene, then yes, it will be null