Magic_Game/Easy2D/Base/EScene.cpp

118 lines
2.2 KiB
C++
Raw Normal View History

#include "..\ebase.h"
#include "..\enodes.h"
2017-10-14 01:07:34 +08:00
#include "..\emsg.h"
2017-10-17 21:22:25 +08:00
#include "..\etools.h"
2017-10-14 18:43:32 +08:00
#include <algorithm>
2017-09-10 23:56:52 +08:00
2017-10-14 18:43:32 +08:00
e2d::EScene::EScene()
: m_bWillSave(true)
, m_bSortNeeded(false)
2017-10-17 21:22:25 +08:00
, m_Root(new ENode())
2017-10-14 18:43:32 +08:00
{
2017-10-17 21:22:25 +08:00
m_Root->_onEnter();
m_Root->_setParentScene(this);
2017-10-14 18:43:32 +08:00
}
2017-09-10 23:56:52 +08:00
e2d::EScene::~EScene()
2017-09-10 23:56:52 +08:00
{
2017-10-17 21:22:25 +08:00
m_Root->autoRelease();
2017-09-10 23:56:52 +08:00
}
void e2d::EScene::onEnter()
{
}
void e2d::EScene::onExit()
{
}
void e2d::EScene::onActivate()
{
}
void e2d::EScene::onInactive()
{
}
bool e2d::EScene::onCloseWindow()
{
return true;
}
2017-10-14 18:43:32 +08:00
void e2d::EScene::_onRender()
2017-09-10 23:56:52 +08:00
{
2017-10-17 21:22:25 +08:00
m_Root->_callOn();
2017-09-10 23:56:52 +08:00
}
void e2d::EScene::_onEnter()
2017-09-18 23:59:08 +08:00
{
2017-10-14 18:43:32 +08:00
// <20><><EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>ж<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>
2017-10-17 21:22:25 +08:00
ETimerManager::_notifyAllTimersBindedWith(this);
EMsgManager::_notifyAllMouseListenersBindedWith(this);
EMsgManager::_notifyAllKeyboardListenersBindedWith(this);
2017-10-14 18:43:32 +08:00
//ActionManager::notifyAllSceneActions(m_pNextScene);
2017-09-18 23:59:08 +08:00
}
void e2d::EScene::_onExit()
2017-09-18 23:59:08 +08:00
{
2017-10-14 18:43:32 +08:00
if (m_bWillSave)
{
2017-10-17 21:22:25 +08:00
ETimerManager::_waitAllTimersBindedWith(this);
EMsgManager::_waitAllMouseListenersBindedWith(this);
EMsgManager::_waitAllKeyboardListenersBindedWith(this);
2017-10-14 18:43:32 +08:00
//ActionManager::waitAllSceneActions(m_pCurrentScene);
}
else
{
2017-10-17 21:22:25 +08:00
ETimerManager::clearAllTimersBindedWith(this);
EMsgManager::clearAllMouseListenersBindedWith(this);
EMsgManager::clearAllKeyboardListenersBindedWith(this);
2017-10-14 18:43:32 +08:00
//ActionManager::stopAllSceneActions(m_pCurrentScene);
}
2017-09-18 23:59:08 +08:00
}
2017-10-14 18:43:32 +08:00
void e2d::EScene::add(ENode * child, int order /* = 0 */)
2017-09-10 23:56:52 +08:00
{
2017-10-17 21:22:25 +08:00
m_Root->addChild(child, order);
2017-09-10 23:56:52 +08:00
}
2017-10-17 21:22:25 +08:00
bool e2d::EScene::remove(ENode * child, bool release /* = false */)
2017-09-10 23:56:52 +08:00
{
2017-10-17 21:22:25 +08:00
return m_Root->removeChild(child, release);
}
2017-09-10 23:56:52 +08:00
2017-10-17 21:22:25 +08:00
void e2d::EScene::remove(const EString &childName, bool release /* = false */)
{
return m_Root->removeChild(childName, release);
2017-09-10 23:56:52 +08:00
}
2017-10-17 21:22:25 +08:00
e2d::EVector<e2d::ENode*>& e2d::EScene::getChildren()
{
2017-10-17 21:22:25 +08:00
return m_Root->m_vChildren;
}
2017-10-14 18:43:32 +08:00
size_t e2d::EScene::getChildrenCount() const
{
2017-10-17 21:22:25 +08:00
return m_Root->getChildrenCount();
2017-10-14 18:43:32 +08:00
}
2017-10-17 21:22:25 +08:00
e2d::ENode * e2d::EScene::getChild(const EString &childName)
2017-10-14 18:43:32 +08:00
{
2017-10-17 21:22:25 +08:00
return m_Root->getChild(childName);
2017-10-14 18:43:32 +08:00
}
void e2d::EScene::clearAllChildren()
2017-09-10 23:56:52 +08:00
{
2017-10-17 21:22:25 +08:00
m_Root->clearAllChildren();
2017-10-14 01:07:34 +08:00
}
void e2d::EScene::bindListener(EMouseListener * listener)
{
2017-10-17 21:22:25 +08:00
EMsgManager::bindListener(listener, this);
2017-10-14 01:07:34 +08:00
}
void e2d::EScene::bindListener(EKeyboardListener * listener)
{
2017-10-17 21:22:25 +08:00
EMsgManager::bindListener(listener, this);
2017-10-14 01:07:34 +08:00
}