Files
wnmj-normal/Classes/Scenes/LoadingScene.cpp

95 lines
1.8 KiB
C++
Raw Permalink Normal View History

2026-03-03 13:56:44 +08:00
#include "LoadingScene.h"
SINGLETON_STORAGE(LoadingScene);
LoadingScene::LoadingScene()
{
init();
}
LoadingScene::~LoadingScene()
{
}
bool LoadingScene::init()
{
if (!Node::init())
{
return false;
};
auto visibleSize = Director::getInstance()->getVisibleSize();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD>
auto touchLayer = LayerColor::create(Color4B(0, 0, 0, 50), visibleSize.width, visibleSize.height);
this->addChild(touchLayer);
auto mListener = EventListenerTouchOneByOne::create();
mListener->onTouchBegan = [=](Touch * _touch, Event * _event)
{
return true;
};
mListener->setSwallowTouches(true);
//<2F><><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>ɾ<EFBFBD><C9BE>(addEventListenerWithFixedPriority<74><79>Ҫ<EFBFBD>ֶ<EFBFBD>ɾ<EFBFBD><C9BE>)
_eventDispatcher->addEventListenerWithSceneGraphPriority(mListener, this);
//<2F><><EFBFBD><EFBFBD>loadingͼƬ
m_sprLoading = Sprite::create("common/Img/ico_loding.png");
m_sprLoading->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2));
touchLayer->addChild(m_sprLoading);
return true;
}
void LoadingScene::onEnter()
{
Node::onEnter();
}
void LoadingScene::onEnterTransitionDidFinish()
{
Node::onEnterTransitionDidFinish();
}
void LoadingScene::onExit()
{
Node::onExit();
}
//<2F><>ʾ
void LoadingScene::show(Node* Parent /*= nullptr*/)
{
this->removeFromParent();
// δ<><EFBFBD><E1B9A9>
if (nullptr == Parent)
{
//<2F><><EFBFBD><EFBFBD>û<EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EBB3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵱ǰ<EBB5B1><C7B0><EFBFBD>г<EFBFBD><D0B3><EFBFBD>
if (getParent() == nullptr)
{
Scene* pScene = Director::getInstance()->getRunningScene();
pScene->addChild(this, 99999);
}
}
else
{
Parent->addChild(this, 99999);
}
auto callback = [this](){
hide();
};
auto rotate = Sequence::create(Repeat::create(RotateBy::create(1.6f, 360), 8), CallFunc::create(callback), nullptr);
m_sprLoading->runAction(rotate);
}
//<2F><><EFBFBD><EFBFBD>
void LoadingScene::hide()
{
m_sprLoading->stopAllActions();
this->removeFromParent();
}