fix the index notif staying on all the time

This commit is contained in:
altalk23 2023-10-11 22:16:12 +03:00
parent 0bdb0df702
commit c967b520df
3 changed files with 6 additions and 1 deletions

View file

@ -13,6 +13,7 @@ namespace geode {
class GEODE_DLL SceneManager { class GEODE_DLL SceneManager {
protected: protected:
cocos2d::CCArray* m_persistedNodes; cocos2d::CCArray* m_persistedNodes;
cocos2d::CCScene* m_lastScene = nullptr;
bool setup(); bool setup();

View file

@ -173,7 +173,6 @@ void Notification::show() {
auto winSize = CCDirector::get()->getWinSize(); auto winSize = CCDirector::get()->getWinSize();
this->setPosition(winSize.width / 2, winSize.height / 4); this->setPosition(winSize.width / 2, winSize.height / 4);
this->setZOrder(CCScene::get()->getHighestChildZ() + 100); this->setZOrder(CCScene::get()->getHighestChildZ() + 100);
CCScene::get()->addChild(this);
} }
SceneManager::get()->keepAcrossScenes(this); SceneManager::get()->keepAcrossScenes(this);
m_showing = true; m_showing = true;

View file

@ -23,6 +23,10 @@ SceneManager::~SceneManager() {
} }
void SceneManager::keepAcrossScenes(CCNode* node) { void SceneManager::keepAcrossScenes(CCNode* node) {
if (m_lastScene) {
node->removeFromParentAndCleanup(false);
m_lastScene->addChild(node);
}
m_persistedNodes->addObject(node); m_persistedNodes->addObject(node);
} }
@ -36,4 +40,5 @@ void SceneManager::willSwitchToScene(CCScene* scene) {
node->removeFromParentAndCleanup(false); node->removeFromParentAndCleanup(false);
scene->addChild(node); scene->addChild(node);
} }
m_lastScene = scene;
} }