Magic_Game/Easy2D/Base/EScene.cpp

113 lines
1.9 KiB
C++
Raw Normal View History

#include "..\ebase.h"
#include "..\enodes.h"
#include "..\emanagers.h"
2017-10-17 21:22:25 +08:00
#include "..\etools.h"
#include "..\eactions.h"
2017-10-29 23:48:32 +08:00
#include "..\Win\winbase.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-29 23:48:32 +08:00
, m_bGeometryVisiable(false)
2017-10-19 13:06:14 +08:00
, m_pRoot(new ENode())
2017-10-14 18:43:32 +08:00
{
2017-10-19 13:06:14 +08:00
m_pRoot->_onEnter();
m_pRoot->_setParentScene(this);
2017-10-21 19:09:31 +08:00
m_pRoot->_setSize(EApp::getWidth(), EApp::getHeight());
m_pRoot->setPos(EApp::getWidth() / 2, EApp::getHeight() / 2);
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-21 19:09:31 +08:00
SafeReleaseAndClear(&m_pRoot);
2017-09-10 23:56:52 +08:00
}
void e2d::EScene::onEnter()
{
}
void e2d::EScene::onExit()
{
}
bool e2d::EScene::onActivate()
{
return true;
}
bool e2d::EScene::onInactive()
{
return true;
}
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-29 23:48:32 +08:00
// <20><><EFBFBD>ʸ<EFBFBD><CAB8>ڵ<EFBFBD>
2017-10-19 13:06:14 +08:00
m_pRoot->_callOn();
2017-10-29 23:48:32 +08:00
// <20>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
GetRenderTarget()->SetTransform(D2D1::Matrix3x2F::Identity());
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD>ͼ<EFBFBD><CDBC>
if (m_bGeometryVisiable)
{
m_pRoot->_drawGeometry();
}
2017-09-10 23:56:52 +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-19 13:06:14 +08:00
m_pRoot->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-19 13:06:14 +08:00
return m_pRoot->removeChild(child, release);
2017-10-17 21:22:25 +08:00
}
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 */)
{
2017-10-19 13:06:14 +08:00
return m_pRoot->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-19 13:06:14 +08:00
return m_pRoot->m_vChildren;
}
2017-10-14 18:43:32 +08:00
size_t e2d::EScene::getChildrenCount() const
{
2017-10-19 13:06:14 +08:00
return m_pRoot->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-19 13:06:14 +08:00
return m_pRoot->getChild(childName);
2017-10-14 18:43:32 +08:00
}
e2d::ENode * e2d::EScene::getRoot() const
{
return m_pRoot;
}
void e2d::EScene::clearAllChildren()
2017-09-10 23:56:52 +08:00
{
2017-10-19 13:06:14 +08:00
m_pRoot->clearAllChildren();
2017-10-14 01:07:34 +08:00
}
void e2d::EScene::runAction(EAction * action)
{
this->m_pRoot->runAction(action);
2017-10-29 23:48:32 +08:00
}
void e2d::EScene::setGeometryVisiable(bool visiable)
{
m_bGeometryVisiable = visiable;
}