更新ENode
This commit is contained in:
		
							parent
							
								
									d07f95424a
								
							
						
					
					
						commit
						7f402c7593
					
				|  | @ -23,7 +23,7 @@ | |||
|     <ProjectGuid>{70931955-FE2D-4A50-93C6-6955A730B0FE}</ProjectGuid> | ||||
|     <Keyword>Win32Proj</Keyword> | ||||
|     <RootNamespace>ConsoleDemo</RootNamespace> | ||||
|     <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion> | ||||
|     <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||||
|  |  | |||
|  | @ -23,14 +23,14 @@ | |||
|     <ProjectGuid>{9D85A92F-BCCE-4EF0-BAD3-601C0086661C}</ProjectGuid> | ||||
|     <Keyword>Win32Proj</Keyword> | ||||
|     <RootNamespace>Demo</RootNamespace> | ||||
|     <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion> | ||||
|     <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v141</PlatformToolset> | ||||
|     <CharacterSet>Unicode</CharacterSet> | ||||
|     <PlatformToolset>v141</PlatformToolset> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|  | @ -42,7 +42,7 @@ | |||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||||
|     <ConfigurationType>Application</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v140</PlatformToolset> | ||||
|     <PlatformToolset>v141</PlatformToolset> | ||||
|     <CharacterSet>Unicode</CharacterSet> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||||
|  |  | |||
|  | @ -19,14 +19,11 @@ int WINAPI WinMain( | |||
| 		node->setSize(30, 180); | ||||
| 		scene->add(node); | ||||
| 
 | ||||
| 		auto listener = new EMouseClickListener([=](EPoint) { | ||||
| 			if (EMouseMsg::getMsg() == EMouseMsg::MOUSE_MSG::MOVE) | ||||
| 			{ | ||||
| 				node->setPos(EMouseMsg::getPos()); | ||||
| 			} | ||||
| 		auto mlistener = new EMouseClickListener([=](EPoint) { | ||||
| 			node->setPos(EMouseMsg::getPos()); | ||||
| 		}); | ||||
| 
 | ||||
| 		auto listener = new EKeyPressListener([=] { | ||||
| 		auto klistener = new EKeyPressListener([=] { | ||||
| 			if (EKeyMsg::isCapitalLockOn()) | ||||
| 			{ | ||||
| 				if (EKeyMsg::getVal() == EKeyMsg::KEY::LEFT) | ||||
|  | @ -40,9 +37,9 @@ int WINAPI WinMain( | |||
| 			} | ||||
| 		}); | ||||
| 
 | ||||
| 		listener->bindWithNode(node); | ||||
| 		mlistener->bindWith(node); | ||||
| 
 | ||||
| 		scene->bindListener(listener); | ||||
| 		scene->bindListener(klistener); | ||||
| 
 | ||||
| 		app.enterScene(scene); | ||||
| 
 | ||||
|  |  | |||
|  | @ -46,7 +46,7 @@ void e2d::EScene::add(ENode * child, int zOrder /* = 0 */) | |||
| 	// 忽略空指针
 | ||||
| 	if (child == nullptr) return; | ||||
| 	// 设置节点的父场景
 | ||||
| 	child->bindWithScene(this); | ||||
| 	child->setParentScene(this); | ||||
| 	// 设置 z 轴顺序
 | ||||
| 	child->setZOrder(zOrder); | ||||
| 	// 对象的引用计数加一
 | ||||
|  |  | |||
|  | @ -23,14 +23,14 @@ | |||
|     <ProjectGuid>{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}</ProjectGuid> | ||||
|     <Keyword>Win32Proj</Keyword> | ||||
|     <RootNamespace>Easy2D</RootNamespace> | ||||
|     <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion> | ||||
|     <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> | ||||
|   </PropertyGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>StaticLibrary</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v141</PlatformToolset> | ||||
|     <CharacterSet>Unicode</CharacterSet> | ||||
|     <PlatformToolset>v141</PlatformToolset> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||||
|     <ConfigurationType>StaticLibrary</ConfigurationType> | ||||
|  | @ -42,7 +42,7 @@ | |||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||||
|     <ConfigurationType>StaticLibrary</ConfigurationType> | ||||
|     <UseDebugLibraries>true</UseDebugLibraries> | ||||
|     <PlatformToolset>v140</PlatformToolset> | ||||
|     <PlatformToolset>v141</PlatformToolset> | ||||
|     <CharacterSet>Unicode</CharacterSet> | ||||
|   </PropertyGroup> | ||||
|   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||||
|  | @ -196,7 +196,7 @@ | |||
|     <ClCompile Include="Base\EObject.cpp" /> | ||||
|     <ClCompile Include="Base\EScene.cpp" /> | ||||
|     <ClCompile Include="Msg\EMsgManager.cpp" /> | ||||
|     <ClCompile Include="Msg\Listener\EKeyListener.cpp" /> | ||||
|     <ClCompile Include="Msg\Listener\EKeyboardListener.cpp" /> | ||||
|     <ClCompile Include="Msg\Listener\EKeyPressListener.cpp" /> | ||||
|     <ClCompile Include="Msg\Listener\EListener.cpp" /> | ||||
|     <ClCompile Include="Msg\Listener\EMouseClickListener.cpp" /> | ||||
|  |  | |||
|  | @ -42,9 +42,6 @@ | |||
|     <ClCompile Include="Msg\EMsgManager.cpp"> | ||||
|       <Filter>Msg</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="Msg\Listener\EKeyListener.cpp"> | ||||
|       <Filter>Msg\Listener</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="Msg\Listener\EListener.cpp"> | ||||
|       <Filter>Msg\Listener</Filter> | ||||
|     </ClCompile> | ||||
|  | @ -57,12 +54,15 @@ | |||
|     <ClCompile Include="Msg\Listener\EMouseListener.cpp"> | ||||
|       <Filter>Msg\Listener</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="Msg\Listener\EKeyPressListener.cpp"> | ||||
|       <Filter>Msg\Listener</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="Tool\ETimerManager.cpp"> | ||||
|       <Filter>Tool</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="Msg\Listener\EKeyboardListener.cpp"> | ||||
|       <Filter>Msg\Listener</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="Msg\Listener\EKeyPressListener.cpp"> | ||||
|       <Filter>Msg\Listener</Filter> | ||||
|     </ClCompile> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="Win\winbase.h"> | ||||
|  |  | |||
|  | @ -1,53 +1,53 @@ | |||
| #include "..\..\emsg.h" | ||||
| 
 | ||||
| e2d::EKeyboardListener::EKeyboardListener() | ||||
| 	: EListener() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| e2d::EKeyboardListener::EKeyboardListener(EString name) | ||||
| 	: EListener(name) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| e2d::EKeyboardListener::EKeyboardListener(const KEY_LISTENER_CALLBACK & callback) | ||||
| 	: EListener() | ||||
| { | ||||
| 	m_callback = callback; | ||||
| } | ||||
| 
 | ||||
| e2d::EKeyboardListener::EKeyboardListener(EString name, const KEY_LISTENER_CALLBACK & callback) | ||||
| 	: EListener(name) | ||||
| { | ||||
| 	m_callback = callback; | ||||
| } | ||||
| 
 | ||||
| void e2d::EKeyboardListener::runCallback() | ||||
| { | ||||
| 	m_callback(); | ||||
| } | ||||
| 
 | ||||
| void e2d::EKeyboardListener::setCallback(const KEY_LISTENER_CALLBACK & callback) | ||||
| { | ||||
| 	m_callback = callback; | ||||
| } | ||||
| 
 | ||||
| void e2d::EKeyboardListener::bindWithScene(EScene * pParentScene) | ||||
| { | ||||
| 	WARN_IF(m_pParentScene != nullptr || m_pParentNode != nullptr, "EListener cannot bind with two object."); | ||||
| 
 | ||||
| 	if (pParentScene) | ||||
| 	{ | ||||
| 		EMsgManager::bindListenerWith(this, pParentScene); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void e2d::EKeyboardListener::bindWithNode(ENode * pParentNode) | ||||
| { | ||||
| 	WARN_IF(m_pParentScene != nullptr || m_pParentNode != nullptr, "EListener cannot bind with two object."); | ||||
| 
 | ||||
| 	if (pParentNode != nullptr && m_pParentScene == nullptr) | ||||
| 	{ | ||||
| 		EMsgManager::bindListenerWith(this, pParentNode); | ||||
| 	} | ||||
| #include "..\..\emsg.h" | ||||
| 
 | ||||
| e2d::EKeyboardListener::EKeyboardListener() | ||||
| 	: EListener() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| e2d::EKeyboardListener::EKeyboardListener(EString name) | ||||
| 	: EListener(name) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| e2d::EKeyboardListener::EKeyboardListener(const KEY_LISTENER_CALLBACK & callback) | ||||
| 	: EListener() | ||||
| { | ||||
| 	m_callback = callback; | ||||
| } | ||||
| 
 | ||||
| e2d::EKeyboardListener::EKeyboardListener(EString name, const KEY_LISTENER_CALLBACK & callback) | ||||
| 	: EListener(name) | ||||
| { | ||||
| 	m_callback = callback; | ||||
| } | ||||
| 
 | ||||
| void e2d::EKeyboardListener::runCallback() | ||||
| { | ||||
| 	m_callback(); | ||||
| } | ||||
| 
 | ||||
| void e2d::EKeyboardListener::setCallback(const KEY_LISTENER_CALLBACK & callback) | ||||
| { | ||||
| 	m_callback = callback; | ||||
| } | ||||
| 
 | ||||
| void e2d::EKeyboardListener::bindWith(EScene * pParentScene) | ||||
| { | ||||
| 	WARN_IF(m_pParentScene != nullptr || m_pParentNode != nullptr, "EListener cannot bind with two object."); | ||||
| 
 | ||||
| 	if (pParentScene) | ||||
| 	{ | ||||
| 		EMsgManager::bindListenerWith(this, pParentScene); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void e2d::EKeyboardListener::bindWith(ENode * pParentNode) | ||||
| { | ||||
| 	WARN_IF(m_pParentScene != nullptr || m_pParentNode != nullptr, "EListener cannot bind with two object."); | ||||
| 
 | ||||
| 	if (pParentNode != nullptr && m_pParentScene == nullptr) | ||||
| 	{ | ||||
| 		EMsgManager::bindListenerWith(this, pParentNode); | ||||
| 	} | ||||
| } | ||||
|  | @ -24,8 +24,7 @@ e2d::EMouseClickListener::EMouseClickListener(EString name, const MOUSE_CLICK_LI | |||
| 
 | ||||
| void e2d::EMouseClickListener::runCallback() | ||||
| { | ||||
| 	if (EMouseMsg::getMsg() == EMouseMsg::MOUSE_MSG::LBUTTON_DOWN ||  | ||||
| 		EMouseMsg::getMsg() == EMouseMsg::MOUSE_MSG::LBUTTON_DBLCLK) | ||||
| 	if (EMouseMsg::getMsg() == EMouseMsg::MOUSE_MSG::LBUTTON_UP) | ||||
| 	{ | ||||
| 		m_callback(EMouseMsg::getPos()); | ||||
| 	} | ||||
|  |  | |||
|  | @ -4,30 +4,22 @@ | |||
| e2d::ENode::ENode() | ||||
| 	: m_nZOrder(0) | ||||
| 	, m_bVisiable(true) | ||||
| 	, m_pParent(nullptr) | ||||
| 	, m_pParentScene(nullptr) | ||||
| 	, m_nHashName(0) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| e2d::ENode::ENode(EPoint p)  | ||||
| e2d::ENode::ENode(EString name) | ||||
| 	: ENode() | ||||
| { | ||||
| 	setPos(p); | ||||
| } | ||||
| 
 | ||||
| e2d::ENode::ENode(int x, int y) | ||||
| 	: ENode() | ||||
| { | ||||
| 	setPos(x, y); | ||||
| 	setName(name); | ||||
| } | ||||
| 
 | ||||
| e2d::ENode::~ENode() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| bool e2d::ENode::_exec(bool active) | ||||
| { | ||||
| 	return false; | ||||
| } | ||||
| 
 | ||||
| void e2d::ENode::_onRender() | ||||
| { | ||||
| 	D2D1_RECT_F rectangle = D2D1::RectF( | ||||
|  | @ -173,6 +165,19 @@ void e2d::ENode::setParent(ENode * parent) | |||
| 	m_pParent = parent; | ||||
| } | ||||
| 
 | ||||
| void e2d::ENode::addChild(ENode * child) | ||||
| { | ||||
| 	WARN_IF(child == nullptr, "NULL ENode pointer exception."); | ||||
| 
 | ||||
| 	if (child) | ||||
| 	{ | ||||
| 		for (ENode * parent = this; parent != nullptr; parent = parent->getParent()) | ||||
| 		{ | ||||
| 			ASSERT(child != parent, "A ENode cannot be the child of his own children"); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| e2d::ENode *& e2d::ENode::getParent() | ||||
| { | ||||
| 	return m_pParent; | ||||
|  | @ -183,16 +188,68 @@ e2d::EScene * &e2d::ENode::getParentScene() | |||
| 	return m_pParentScene; | ||||
| } | ||||
| 
 | ||||
| void e2d::ENode::bindWithScene(EScene * scene) | ||||
| std::vector<e2d::ENode*>& e2d::ENode::getChildren() | ||||
| { | ||||
| 	return m_vChildren; | ||||
| } | ||||
| 
 | ||||
| int e2d::ENode::getChildrenCount() const | ||||
| { | ||||
| 	return m_vChildren.size(); | ||||
| } | ||||
| 
 | ||||
| e2d::ENode * e2d::ENode::getChild(EString name) | ||||
| { | ||||
| 	WARN_IF(name.empty(), "Invalid ENode name."); | ||||
| 
 | ||||
| 	std::hash<EString> h; | ||||
| 	size_t hash = h(name); | ||||
| 
 | ||||
| 	for (const auto& child : m_vChildren) | ||||
| 	{ | ||||
| 		// 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度
 | ||||
| 		if (child->m_nHashName == hash && child->m_sName == name) | ||||
| 			return child; | ||||
| 	} | ||||
| 	return nullptr; | ||||
| } | ||||
| 
 | ||||
| void e2d::ENode::setParentScene(EScene * scene) | ||||
| { | ||||
| 	m_pParentScene = scene; | ||||
| } | ||||
| 
 | ||||
| void e2d::ENode::removeFromParent(bool release) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void e2d::ENode::removeChild(ENode * child, bool release) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void e2d::ENode::removeChild(EString childName, bool release) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void e2d::ENode::setVisiable(bool value) | ||||
| { | ||||
| 	m_bVisiable = value; | ||||
| } | ||||
| 
 | ||||
| void e2d::ENode::setName(EString name) | ||||
| { | ||||
| 	WARN_IF(name.empty(), "Invalid ENode name."); | ||||
| 
 | ||||
| 	if (!name.empty()) | ||||
| 	{ | ||||
| 		// 保存节点名
 | ||||
| 		m_sName = name; | ||||
| 		// 保存节点 Hash 名
 | ||||
| 		std::hash<EString> h; | ||||
| 		m_nHashName = h(name); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| bool e2d::ENode::isVisiable() const | ||||
| { | ||||
| 	return m_bVisiable; | ||||
|  |  | |||
|  | @ -20,12 +20,12 @@ | |||
| 
 | ||||
| // Windows Header Files:
 | ||||
| #include <windows.h> | ||||
| 
 | ||||
| #include <assert.h> | ||||
| 
 | ||||
| 
 | ||||
| #ifndef ASSERT_IF | ||||
| #if defined( DEBUG ) || defined( _DEBUG ) | ||||
| #define ASSERT(b, m) do {if (!(b)) { fprintf(stderr, "Assert: " #m "\n"); abort(); }} while(0) | ||||
| #define ASSERT(b, m) do {if (!(b)) { fprintf(stderr, "Assert: " #m "\n"); assert(b); }} while(0) | ||||
| #else | ||||
| 	#define ASSERT(b, m) ((void)0) | ||||
| #endif //DEBUG || _DEBUG
 | ||||
|  |  | |||
|  | @ -183,12 +183,12 @@ public: | |||
| 	); | ||||
| 
 | ||||
| 	// 绑定监听器到场景
 | ||||
| 	virtual void bindWithScene( | ||||
| 	virtual void bindWith( | ||||
| 		EScene * pParentScene | ||||
| 	) = 0; | ||||
| 
 | ||||
| 	// 绑定监听器到节点
 | ||||
| 	virtual void bindWithNode( | ||||
| 	virtual void bindWith( | ||||
| 		ENode * pParentNode | ||||
| 	) = 0; | ||||
| 
 | ||||
|  | @ -232,12 +232,12 @@ public: | |||
| 	// 绑定监听器到场景
 | ||||
| 	virtual void bindWith( | ||||
| 		EScene * pParentScene | ||||
| 	); | ||||
| 	) override; | ||||
| 
 | ||||
| 	// 绑定监听器到节点
 | ||||
| 	virtual void bindWith( | ||||
| 		ENode * pParentNode | ||||
| 	); | ||||
| 	) override; | ||||
| 
 | ||||
| protected: | ||||
| 	MOUSE_LISTENER_CALLBACK m_callback; | ||||
|  | @ -341,14 +341,14 @@ public: | |||
| 	); | ||||
| 
 | ||||
| 	// 绑定监听器到场景
 | ||||
| 	virtual void bindWithScene( | ||||
| 	virtual void bindWith( | ||||
| 		EScene * pParentScene | ||||
| 	); | ||||
| 	) override; | ||||
| 
 | ||||
| 	// 绑定监听器到节点
 | ||||
| 	virtual void bindWithNode( | ||||
| 	virtual void bindWith( | ||||
| 		ENode * pParentNode | ||||
| 	); | ||||
| 	) override; | ||||
| 
 | ||||
| protected: | ||||
| 	KEY_LISTENER_CALLBACK m_callback; | ||||
|  |  | |||
|  | @ -4,9 +4,6 @@ | |||
| namespace e2d  | ||||
| { | ||||
| 
 | ||||
| class EScene; | ||||
| class EObject; | ||||
| 
 | ||||
| class ENode : | ||||
| 	public EObject | ||||
| { | ||||
|  | @ -16,12 +13,7 @@ public: | |||
| 	ENode(); | ||||
| 
 | ||||
| 	ENode( | ||||
| 		EPoint p | ||||
| 	); | ||||
| 
 | ||||
| 	ENode( | ||||
| 		int x,  | ||||
| 		int y | ||||
| 		EString name | ||||
| 	); | ||||
| 
 | ||||
| 	virtual ~ENode(); | ||||
|  | @ -48,22 +40,34 @@ public: | |||
| 	virtual UINT32 getHeight() const; | ||||
| 
 | ||||
| 	// 获取节点大小
 | ||||
| 	virtual e2d::ESize getSize() const; | ||||
| 	virtual ESize getSize() const; | ||||
| 
 | ||||
| 	// 获取节点所在的矩形
 | ||||
| 	virtual e2d::ERect getRect() const; | ||||
| 	virtual ERect getRect() const; | ||||
| 
 | ||||
| 	// 获取父节点
 | ||||
| 	virtual e2d::ENode* &getParent(); | ||||
| 	virtual ENode * &getParent(); | ||||
| 
 | ||||
| 	// 获取节点所在场景
 | ||||
| 	EScene * &getParentScene(); | ||||
| 	virtual EScene * &getParentScene(); | ||||
| 
 | ||||
| 	// 获取所有子节点
 | ||||
| 	virtual std::vector<ENode*> &getChildren(); | ||||
| 
 | ||||
| 	// 获取子节点数量
 | ||||
| 	virtual int getChildrenCount() const; | ||||
| 
 | ||||
| 	// 根据名字获取子节点
 | ||||
| 	virtual ENode * getChild(EString name); | ||||
| 
 | ||||
| 	// 设置节点是否显示
 | ||||
| 	virtual void setVisiable( | ||||
| 		bool value | ||||
| 	); | ||||
| 
 | ||||
| 	// 设置节点名称
 | ||||
| 	virtual void setName(EString name); | ||||
| 
 | ||||
| 	// 设置节点横坐标
 | ||||
| 	virtual void setX( | ||||
| 		int x | ||||
|  | @ -114,7 +118,7 @@ public: | |||
| 
 | ||||
| 	// 设置节点大小
 | ||||
| 	virtual void setSize( | ||||
| 		e2d::ESize size | ||||
| 		ESize size | ||||
| 	); | ||||
| 
 | ||||
| 	// 设置节点所在的矩形
 | ||||
|  | @ -133,7 +137,7 @@ public: | |||
| 
 | ||||
| 	// 设置节点所在的矩形
 | ||||
| 	virtual void setRect( | ||||
| 		e2d::ERect rect | ||||
| 		ERect rect | ||||
| 	); | ||||
| 
 | ||||
| 	// 设置节点绘图顺序(0为最先绘制,显示在最底层)
 | ||||
|  | @ -141,28 +145,41 @@ public: | |||
| 		int z | ||||
| 	); | ||||
| 
 | ||||
| 	// 设置节点所在场景
 | ||||
| 	virtual void setParentScene( | ||||
| 		EScene * scene | ||||
| 	); | ||||
| 
 | ||||
| 	// 设置父节点
 | ||||
| 	virtual void setParent( | ||||
| 		ENode* parent | ||||
| 	); | ||||
| 
 | ||||
| 	// 设置节点所在场景
 | ||||
| 	void bindWithScene( | ||||
| 		EScene * scene | ||||
| 	); | ||||
| 	// 添加子节点
 | ||||
| 	virtual void addChild(ENode * child); | ||||
| 
 | ||||
| 	// 从父节点移除
 | ||||
| 	virtual void removeFromParent(bool release = false); | ||||
| 
 | ||||
| 	// 移除子节点
 | ||||
| 	virtual void removeChild(ENode * child, bool release = false); | ||||
| 
 | ||||
| 	// 移除子节点
 | ||||
| 	virtual void removeChild(EString childName, bool release = false); | ||||
| 
 | ||||
| protected: | ||||
| 	// 渲染节点
 | ||||
| 	virtual void _onRender(); | ||||
| 
 | ||||
| protected: | ||||
| 	EString		m_sName; | ||||
| 	size_t		m_nHashName; | ||||
| 	int			m_nZOrder; | ||||
| 	bool		m_bVisiable; | ||||
| 	ERect		m_Rect; | ||||
| 	EScene *	m_pParentScene; | ||||
| 	ENode *		m_pParent; | ||||
| 
 | ||||
| protected: | ||||
| 
 | ||||
| 	virtual bool _exec(bool active); | ||||
| 
 | ||||
| 	virtual void _onRender(); | ||||
| 	std::vector<ENode*> m_vChildren; | ||||
| }; | ||||
| 
 | ||||
| } | ||||
		Loading…
	
		Reference in New Issue