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

126 lines
3.1 KiB
C++
Raw Normal View History

2026-03-03 13:56:44 +08:00
#include "ShowScene.h"
#include "MissionWeiXin.h"
#include "SimpleAudioEngine.h"
#include "UserInfo.h"
#include "GlobalJosn.h"
ShowScene::ShowScene()
{
m_rootPanel = nullptr;
}
ShowScene::~ShowScene()
{
}
bool ShowScene::init()
{
if (!Node::init())
{
return false;
};
auto rootPanel = CSLoader::createNode("Platform/ShowScene.csb");
CC_ASSERT(rootPanel != nullptr);
this->addChild(rootPanel);
m_rootPanel = (ImageView*)rootPanel->getChildByName("Imagebg");
CC_ASSERT(m_rootPanel != nullptr);
//<2F><>ȡ<EFBFBD>رհ<D8B1>ť
auto btnClose = (Button*)m_rootPanel->getChildByName("btnClose");
CC_ASSERT(btnClose != nullptr);
//ע<><D7A2><EFBFBD>رհ<D8B1>ť<EFBFBD>¼<EFBFBD>
btnClose->addClickEventListener([this](Ref*){
YSAudioEngine::Instance().playBtnClickEffect();
//this->removeFromParent();
this->popScene();
});
// ΢<><CEA2>
auto btnWeiXin = (Button*)m_rootPanel->getChildByName("btnWeiXin");
CC_ASSERT(btnWeiXin != nullptr);
//ע<><D7A2><EFBFBD>رհ<D8B1>ť<EFBFBD>¼<EFBFBD>
btnWeiXin->addClickEventListener([this](Ref*){
YSAudioEngine::Instance().playBtnClickEffect();
std::string strUrl = GlobalJosn::getInstance()->getShareInfoByKind(SH_KIND_WEIXIN_URL);
std::string strTitle = GlobalJosn::getInstance()->getShareInfoByKind(SH_KIND_WEIXIN_TITLE);
std::string strComment = GlobalJosn::getInstance()->getShareInfoByKind(SH_KIND_WEIXIN_COMMET);
MissionWeiXin::Instance().shareUrlWeiXin(strUrl, strTitle, strComment);
this->removeFromParent();
});
// <20><><EFBFBD><EFBFBD>Ȧ
auto btnMoments = (Button*)m_rootPanel->getChildByName("btnMoments");
CC_ASSERT(btnMoments != nullptr);
//ע<><D7A2><EFBFBD>رհ<D8B1>ť<EFBFBD>¼<EFBFBD>
btnMoments->addClickEventListener([this](Ref*){
YSAudioEngine::Instance().playBtnClickEffect();
std::string strUrl = GlobalJosn::getInstance()->getShareInfoByKind(SH_KIND_FRIEND_RUL);
std::string strTitle = GlobalJosn::getInstance()->getShareInfoByKind(SH_KIND_FRIEND_TITLE);
std::string strComment = GlobalJosn::getInstance()->getShareInfoByKind(SH_KIND_FRIEND_COMMET);
MissionWeiXin::Instance().shareUrlWeiXin(strUrl, strTitle, strTitle, 1);
#if (CC_TARGET_PLATFORM==CC_PLATFORM_WIN32)
auto dispatcher = Director::getInstance()->getEventDispatcher();
EventCustom event(WXSHARE_FRIENDS_SUCCESS);
//<2F>ɷ<EFBFBD><C9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ShowScene
dispatcher->dispatchEvent(&event);
#endif
this->removeFromParent();
});
// txtTip;
auto txtTip = (Text*)m_rootPanel->getChildByName("txtTip");
ASSERT(txtTip != nullptr);
txtTip->setString(GlobalJosn::getInstance()->m_strShareTip);
return true;
}
void ShowScene::onEnter()
{
Node::onEnter();
}
void ShowScene::onEnterTransitionDidFinish()
{
Node::onEnterTransitionDidFinish();
}
void ShowScene::onExit()
{
Node::onExit();
}
void ShowScene::pushScene()
{
if (m_rootPanel)
{
this->setVisible(true);
m_rootPanel->setScale(0.8f);
m_rootPanel->runAction(Sequence::create(Show::create(), ScaleTo::create(0.2f, 1.2f), ScaleTo::create(0.1f, 1.f), CallFunc::create([&]()
{
}), nullptr));
}
}
void ShowScene::popScene()
{
if (m_rootPanel)
{
m_rootPanel->runAction(Sequence::create(Hide::create(), ScaleTo::create(0.1f, 0.1f), CallFunc::create([&]()
{
this->setVisible(false);
}), nullptr));
}
}