| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  |  | #include "..\e2dnode.h"
 | 
					
						
							|  |  |  |  | #include "..\e2dmanager.h"
 | 
					
						
							|  |  |  |  | #include "..\e2daction.h"
 | 
					
						
							|  |  |  |  | #include "..\e2dcollider.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | #include <algorithm>
 | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | // Ĭ<><C4AC><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>λ<EFBFBD><CEBB>
 | 
					
						
							|  |  |  |  | static float s_fDefaultPiovtX = 0; | 
					
						
							|  |  |  |  | static float s_fDefaultPiovtY = 0; | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | static bool s_fDefaultColliderEnabled = true; | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::Node::Node() | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	: m_nOrder(0) | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	, m_fPosX(0) | 
					
						
							|  |  |  |  | 	, m_fPosY(0) | 
					
						
							|  |  |  |  | 	, m_fWidth(0) | 
					
						
							|  |  |  |  | 	, m_fHeight(0) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	, m_fScaleX(1.0f) | 
					
						
							|  |  |  |  | 	, m_fScaleY(1.0f) | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	, m_fRotation(0) | 
					
						
							|  |  |  |  | 	, m_fSkewAngleX(0) | 
					
						
							|  |  |  |  | 	, m_fSkewAngleY(0) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	, m_fDisplayOpacity(1.0f) | 
					
						
							|  |  |  |  | 	, m_fRealOpacity(1.0f) | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	, m_fPivotX(s_fDefaultPiovtX) | 
					
						
							|  |  |  |  | 	, m_fPivotY(s_fDefaultPiovtY) | 
					
						
							|  |  |  |  | 	, m_MatriInitial(D2D1::Matrix3x2F::Identity()) | 
					
						
							|  |  |  |  | 	, m_MatriFinal(D2D1::Matrix3x2F::Identity()) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | 	, m_bVisiable(true) | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	, m_bDisplayedInScene(false) | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	, m_pCollider(nullptr) | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 	, m_pParent(nullptr) | 
					
						
							|  |  |  |  | 	, m_pParentScene(nullptr) | 
					
						
							|  |  |  |  | 	, m_nHashName(0) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	, m_bSortChildrenNeeded(false) | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	, m_bTransformNeeded(false) | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 	, m_bAutoUpdate(true) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	if (s_fDefaultColliderEnabled) | 
					
						
							| 
									
										
										
										
											2018-03-07 20:14:58 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		auto rect = new ColliderRect(this); | 
					
						
							|  |  |  |  | 		this->setCollider(rect); | 
					
						
							| 
									
										
										
										
											2018-03-07 20:14:58 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::Node::~Node() | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::_update() | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	if (m_bTransformNeeded) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | 		_updateTransform(); | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (!m_vChildren.empty()) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 		if (m_bSortChildrenNeeded) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-02-11 20:48:56 +08:00
										 |  |  |  | 			// <20>ӽڵ<D3BD><DAB5><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 			auto sortFunc = [](Node * n1, Node * n2) { | 
					
						
							|  |  |  |  | 				return n1->getOrder() < n2->getOrder(); | 
					
						
							|  |  |  |  | 			}; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 			std::sort( | 
					
						
							|  |  |  |  | 				std::begin(m_vChildren), | 
					
						
							|  |  |  |  | 				std::end(m_vChildren), | 
					
						
							| 
									
										
										
										
											2018-02-11 20:48:56 +08:00
										 |  |  |  | 				sortFunc | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 			); | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 			m_bSortChildrenNeeded = false; | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>ӽڵ<D3BD>
 | 
					
						
							| 
									
										
										
										
											2017-12-15 23:15:06 +08:00
										 |  |  |  | 		size_t size = m_vChildren.size(); | 
					
						
							|  |  |  |  | 		size_t i; | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 		for (i = 0; i < size; i++) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			auto child = m_vChildren[i]; | 
					
						
							|  |  |  |  | 			// <20><><EFBFBD><EFBFBD> Order С<><D0A1><EFBFBD><EFBFBD><EFBFBD>Ľڵ<C4BD>
 | 
					
						
							|  |  |  |  | 			if (child->getOrder() < 0) | 
					
						
							|  |  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2018-02-06 21:11:54 +08:00
										 |  |  |  | 				child->_update(); | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 			else | 
					
						
							|  |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				break; | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-06 21:11:54 +08:00
										 |  |  |  | 		if (m_bAutoUpdate) | 
					
						
							| 
									
										
										
										
											2018-02-04 21:24:27 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 			if (!Game::isPaused()) | 
					
						
							| 
									
										
										
										
											2018-02-06 21:11:54 +08:00
										 |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				this->onUpdate(); | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 			this->onFixedUpdate(); | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD>ڵ<EFBFBD>
 | 
					
						
							|  |  |  |  | 		for (; i < size; i++) | 
					
						
							| 
									
										
										
										
											2018-02-06 21:11:54 +08:00
										 |  |  |  | 			m_vChildren[i]->_update(); | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	else | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-02-06 21:11:54 +08:00
										 |  |  |  | 		if (m_bAutoUpdate) | 
					
						
							| 
									
										
										
										
											2018-02-04 21:24:27 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 			if (!Game::isPaused()) | 
					
						
							| 
									
										
										
										
											2018-02-06 21:11:54 +08:00
										 |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				this->onUpdate(); | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 			this->onFixedUpdate(); | 
					
						
							| 
									
										
										
										
											2018-02-04 21:24:27 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::_render() | 
					
						
							| 
									
										
										
										
											2017-10-13 11:42:36 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 	if (!m_bVisiable) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		return; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (!m_vChildren.empty()) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		size_t size = m_vChildren.size(); | 
					
						
							|  |  |  |  | 		size_t i; | 
					
						
							|  |  |  |  | 		for (i = 0; i < size; i++) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			auto child = m_vChildren[i]; | 
					
						
							|  |  |  |  | 			// <20><><EFBFBD><EFBFBD> Order С<><D0A1><EFBFBD><EFBFBD><EFBFBD>Ľڵ<C4BD>
 | 
					
						
							|  |  |  |  | 			if (child->getOrder() < 0) | 
					
						
							|  |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				child->_render(); | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 			else | 
					
						
							|  |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				break; | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		// ת<><D7AA><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD>Ķ<EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 		Renderer::getRenderTarget()->SetTransform(m_MatriFinal); | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 		// <20><>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 		this->onRender(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD>ڵ<EFBFBD>
 | 
					
						
							|  |  |  |  | 		for (; i < size; i++) | 
					
						
							|  |  |  |  | 			m_vChildren[i]->_render(); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	else | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// ת<><D7AA><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD>Ķ<EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 		Renderer::getRenderTarget()->SetTransform(m_MatriFinal); | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 		// <20><>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 		this->onRender(); | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | void e2d::Node::_drawCollider() | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2>
 | 
					
						
							|  |  |  |  | 	if (m_pCollider && m_pCollider->m_bIsVisiable) | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		m_pCollider->_render(); | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽڵ<D3BD><DAB5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2>
 | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto child : m_vChildren) | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		child->_drawCollider(); | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::_onEnter() | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 	if (!this->m_bDisplayedInScene) | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		this->m_bDisplayedInScene = true; | 
					
						
							|  |  |  |  | 		this->onEnter(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 		for (auto child : m_vChildren) | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 			child->_onEnter(); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::_onExit() | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	if (this->m_bDisplayedInScene) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		this->m_bDisplayedInScene = false; | 
					
						
							|  |  |  |  | 		this->onExit(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 		for (auto child : m_vChildren) | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 			child->_onExit(); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | void e2d::Node::_updateSelfTransform() | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-03-30 01:41:29 +08:00
										 |  |  |  | 	D2D1_POINT_2F pivot = { m_fWidth * m_fPivotX, m_fHeight * m_fPivotY }; | 
					
						
							| 
									
										
										
										
											2018-02-11 20:55:52 +08:00
										 |  |  |  | 	// <20>任 Initial <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽڵ㽫<DAB5><E3BDAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б任
 | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	m_MatriInitial = D2D1::Matrix3x2F::Scale( | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 		m_fScaleX, | 
					
						
							|  |  |  |  | 		m_fScaleY, | 
					
						
							| 
									
										
										
										
											2017-11-04 15:38:41 +08:00
										 |  |  |  | 		pivot | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	) * D2D1::Matrix3x2F::Skew( | 
					
						
							|  |  |  |  | 		m_fSkewAngleX, | 
					
						
							|  |  |  |  | 		m_fSkewAngleY, | 
					
						
							| 
									
										
										
										
											2017-11-04 15:38:41 +08:00
										 |  |  |  | 		pivot | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	) * D2D1::Matrix3x2F::Rotation( | 
					
						
							|  |  |  |  | 		m_fRotation, | 
					
						
							| 
									
										
										
										
											2017-11-04 15:38:41 +08:00
										 |  |  |  | 		pivot | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	) * D2D1::Matrix3x2F::Translation( | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 		m_fPosX, | 
					
						
							|  |  |  |  | 		m_fPosY | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	); | 
					
						
							| 
									
										
										
										
											2018-02-11 20:55:52 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5>任 Final <20><><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-02-11 20:48:56 +08:00
										 |  |  |  | 	m_MatriFinal = m_MatriInitial * D2D1::Matrix3x2F::Translation(-pivot.x, -pivot.y); | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	// <20><EFBFBD><CDB8>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	if (m_pParent) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		m_MatriInitial = m_MatriInitial * m_pParent->m_MatriInitial; | 
					
						
							| 
									
										
										
										
											2018-02-11 20:48:56 +08:00
										 |  |  |  | 		m_MatriFinal = m_MatriFinal * m_pParent->m_MatriInitial; | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | void e2d::Node::_updateTransform() | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-26 17:17:30 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | 	_updateSelfTransform(); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧת<D3A6><D7AA>
 | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | 	if (m_pCollider) | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | 		m_pCollider->_transform(); | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	// <20><>־<EFBFBD><D6BE>ִ<EFBFBD>й<EFBFBD><D0B9>任
 | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | 	m_bTransformNeeded = false; | 
					
						
							|  |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD>ӽڵ<D3BD><DAB5>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>нڵ<D0BD>
 | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto child : this->m_vChildren) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | 		child->_updateTransform(); | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | void e2d::Node::_updateOpacity() | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | 	if (m_pParent) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		m_fDisplayOpacity = m_fRealOpacity * m_pParent->m_fDisplayOpacity; | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto child : m_vChildren) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | 		child->_updateOpacity(); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | bool e2d::Node::isVisiable() const | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	return m_bVisiable; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::String e2d::Node::getName() const | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	return m_sName; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | unsigned int e2d::Node::getHashName() const | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	return m_nHashName; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getPosX() const | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	return m_fPosX; | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getPosY() const | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	return m_fPosY; | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::Point e2d::Node::getPos() const | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	return Point(m_fPosX, m_fPosY); | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getWidth() const | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	return m_fWidth * m_fScaleX; | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getHeight() const | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	return m_fHeight * m_fScaleY; | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getRealWidth() const | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	return m_fWidth; | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getRealHeight() const | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	return m_fHeight; | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::Size e2d::Node::getRealSize() const | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	return Size(m_fWidth, m_fHeight); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getPivotX() const | 
					
						
							| 
									
										
										
										
											2017-10-26 17:17:30 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-04 15:38:41 +08:00
										 |  |  |  | 	return m_fPivotX; | 
					
						
							| 
									
										
										
										
											2017-10-26 17:17:30 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getPivotY() const | 
					
						
							| 
									
										
										
										
											2017-10-26 17:17:30 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-04 15:38:41 +08:00
										 |  |  |  | 	return m_fPivotY; | 
					
						
							| 
									
										
										
										
											2017-10-26 17:17:30 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::Size e2d::Node::getSize() const | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 	return Size(getWidth(), getHeight()); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getScaleX() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	return m_fScaleX; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getScaleY() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	return m_fScaleY; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getSkewX() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	return m_fSkewAngleX; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getSkewY() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	return m_fSkewAngleY; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getRotation() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	return m_fRotation; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | double e2d::Node::getOpacity() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	return m_fRealOpacity; | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-21 18:42:07 +08:00
										 |  |  |  | e2d::NodeProperty e2d::Node::getProperty() const | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	NodeProperty prop; | 
					
						
							|  |  |  |  | 	prop.visable = m_bVisiable; | 
					
						
							|  |  |  |  | 	prop.posX = m_fPosX; | 
					
						
							|  |  |  |  | 	prop.posY = m_fPosY; | 
					
						
							|  |  |  |  | 	prop.width = m_fWidth; | 
					
						
							|  |  |  |  | 	prop.height = m_fHeight; | 
					
						
							|  |  |  |  | 	prop.opacity = m_fRealOpacity; | 
					
						
							|  |  |  |  | 	prop.pivotX = m_fPivotX; | 
					
						
							|  |  |  |  | 	prop.pivotY = m_fPivotY; | 
					
						
							|  |  |  |  | 	prop.scaleX = m_fScaleX; | 
					
						
							|  |  |  |  | 	prop.scaleY = m_fScaleY; | 
					
						
							|  |  |  |  | 	prop.rotation = m_fRotation; | 
					
						
							|  |  |  |  | 	prop.skewAngleX = m_fSkewAngleX; | 
					
						
							|  |  |  |  | 	prop.skewAngleY = m_fSkewAngleY; | 
					
						
							|  |  |  |  | 	return prop; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | e2d::Collider * e2d::Node::getCollider() const | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	return m_pCollider; | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | int e2d::Node::getOrder() const | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	return m_nOrder; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::setOrder(int order) | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	m_nOrder = order; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setPosX(double x) | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	this->setPos(x, m_fPosY); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setPosY(double y) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	this->setPos(m_fPosX, y); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::setPos(const Point & p) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	this->setPos(p.x, p.y); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setPos(double x, double y) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	if (m_fPosX == x && m_fPosY == y) | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	m_fPosX = static_cast<float>(x); | 
					
						
							|  |  |  |  | 	m_fPosY = static_cast<float>(y); | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	m_bTransformNeeded = true; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::movePosX(double x) | 
					
						
							| 
									
										
										
										
											2017-11-03 12:51:01 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	this->movePos(x, 0); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::movePosY(double y) | 
					
						
							| 
									
										
										
										
											2017-11-03 12:51:01 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	this->movePos(0, y); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::movePos(double x, double y) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	this->setPos(m_fPosX + x, m_fPosY + y); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::movePos(const Vector & v) | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-03 12:51:01 +08:00
										 |  |  |  | 	this->movePos(v.x, v.y); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setScaleX(double scaleX) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	this->setScale(scaleX, m_fScaleY); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setScaleY(double scaleY) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	this->setScale(m_fScaleX, scaleY); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setScale(double scale) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	this->setScale(scale, scale); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setScale(double scaleX, double scaleY) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	if (m_fScaleX == scaleX && m_fScaleY == scaleY) | 
					
						
							|  |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	m_fScaleX = static_cast<float>(scaleX); | 
					
						
							|  |  |  |  | 	m_fScaleY = static_cast<float>(scaleY); | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	m_bTransformNeeded = true; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setSkewX(double angleX) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	this->setSkew(angleX, m_fSkewAngleY); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setSkewY(double angleY) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	this->setSkew(m_fSkewAngleX, angleY); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setSkew(double angleX, double angleY) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 	if (m_fSkewAngleX == angleX && m_fSkewAngleY == angleY) | 
					
						
							|  |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	m_fSkewAngleX = static_cast<float>(angleX); | 
					
						
							|  |  |  |  | 	m_fSkewAngleY = static_cast<float>(angleY); | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	m_bTransformNeeded = true; | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setRotation(double angle) | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	if (m_fRotation == angle) | 
					
						
							|  |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	m_fRotation = static_cast<float>(angle); | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	m_bTransformNeeded = true; | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setOpacity(double opacity) | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	if (m_fRealOpacity == opacity) | 
					
						
							|  |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	m_fDisplayOpacity = m_fRealOpacity = min(max(static_cast<float>(opacity), 0), 1); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	// <20><><EFBFBD>½ڵ<C2BD><EFBFBD><CDB8><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | 	_updateOpacity(); | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setPivotX(double pivotX) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-04 15:38:41 +08:00
										 |  |  |  | 	this->setPivot(pivotX, m_fPivotY); | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setPivotY(double pivotY) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-04 15:38:41 +08:00
										 |  |  |  | 	this->setPivot(m_fPivotX, pivotY); | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setPivot(double pivotX, double pivotY) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-11-04 15:38:41 +08:00
										 |  |  |  | 	if (m_fPivotX == pivotX && m_fPivotY == pivotY) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	m_fPivotX = min(max(static_cast<float>(pivotX), 0), 1); | 
					
						
							|  |  |  |  | 	m_fPivotY = min(max(static_cast<float>(pivotY), 0), 1); | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	m_bTransformNeeded = true; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-01 19:28:22 +08:00
										 |  |  |  | void e2d::Node::setWidth(double width) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	this->setSize(width, m_fHeight); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void e2d::Node::setHeight(double height) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	this->setSize(m_fWidth, height); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void e2d::Node::setSize(double width, double height) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	if (m_fWidth == width && m_fHeight == height) | 
					
						
							|  |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	m_fWidth = static_cast<float>(width); | 
					
						
							|  |  |  |  | 	m_fHeight = static_cast<float>(height); | 
					
						
							|  |  |  |  | 	m_bTransformNeeded = true; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void e2d::Node::setSize(Size size) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	this->setSize(size.width, size.height); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-21 18:42:07 +08:00
										 |  |  |  | void e2d::Node::setProperty(NodeProperty prop) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	this->setVisiable(prop.visable); | 
					
						
							|  |  |  |  | 	this->setPos(prop.posX, prop.posY); | 
					
						
							|  |  |  |  | 	this->setSize(prop.width, prop.height); | 
					
						
							|  |  |  |  | 	this->setOpacity(prop.opacity); | 
					
						
							|  |  |  |  | 	this->setPivot(prop.pivotX, prop.pivotY); | 
					
						
							|  |  |  |  | 	this->setScale(prop.scaleX, prop.scaleY); | 
					
						
							|  |  |  |  | 	this->setRotation(prop.rotation); | 
					
						
							|  |  |  |  | 	this->setSkew(prop.skewAngleX, prop.skewAngleY); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 21:22:34 +08:00
										 |  |  |  | void e2d::Node::setCollider(ColliderType nColliderType) | 
					
						
							| 
									
										
										
										
											2018-03-31 11:59:51 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	switch (nColliderType) | 
					
						
							| 
									
										
										
										
											2018-03-31 11:59:51 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	case ColliderType::RECT: | 
					
						
							| 
									
										
										
										
											2018-03-31 11:59:51 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		auto rect = new ColliderRect(this); | 
					
						
							|  |  |  |  | 		this->setCollider(rect); | 
					
						
							| 
									
										
										
										
											2018-03-31 11:59:51 +08:00
										 |  |  |  | 		break; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	case ColliderType::CIRCLE: | 
					
						
							| 
									
										
										
										
											2018-03-31 11:59:51 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		auto rect = new ColliderCircle(this); | 
					
						
							|  |  |  |  | 		this->setCollider(rect); | 
					
						
							| 
									
										
										
										
											2018-03-31 11:59:51 +08:00
										 |  |  |  | 		break; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	case ColliderType::ELLIPSE: | 
					
						
							| 
									
										
										
										
											2018-03-31 11:59:51 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		auto rect = new ColliderEllipse(this); | 
					
						
							|  |  |  |  | 		this->setCollider(rect); | 
					
						
							| 
									
										
										
										
											2018-03-31 11:59:51 +08:00
										 |  |  |  | 		break; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	default: | 
					
						
							|  |  |  |  | 		break; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | void e2d::Node::setCollider(Collider * pCollider) | 
					
						
							| 
									
										
										
										
											2017-10-26 17:17:30 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	// ɾ<><C9BE><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>ײ<EFBFBD><D7B2>
 | 
					
						
							|  |  |  |  | 	ColliderManager::__removeCollider(m_pCollider); | 
					
						
							|  |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD>ײ<EFBFBD><D7B2>
 | 
					
						
							|  |  |  |  | 	ColliderManager::__addCollider(pCollider); | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	if (pCollider) | 
					
						
							| 
									
										
										
										
											2017-10-28 18:48:21 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | 		// ˫<><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		this->m_pCollider = pCollider; | 
					
						
							|  |  |  |  | 		pCollider->m_pParentNode = this; | 
					
						
							| 
									
										
										
										
											2017-10-28 18:48:21 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | 	else | 
					
						
							| 
									
										
										
										
											2017-10-28 18:48:21 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		this->m_pCollider = nullptr; | 
					
						
							| 
									
										
										
										
											2017-10-28 18:48:21 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-26 17:17:30 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | void e2d::Node::addColliableName(String collliderName) | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	unsigned int hash = collliderName.getHashCode(); | 
					
						
							|  |  |  |  | 	m_vColliders.insert(hash); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | #ifdef HIGHER_THAN_VS2012
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | void e2d::Node::addColliableName(const InitList<String>& vCollliderName) | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	for (const auto &name : vCollliderName) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		this->addColliableName(name); | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-04-01 13:16:07 +08:00
										 |  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | void e2d::Node::removeColliableName(String collliderName) | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	unsigned int hash = collliderName.getHashCode(); | 
					
						
							|  |  |  |  | 	m_vColliders.erase(hash); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::addChild(Node * child, int order  /* = 0 */) | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 	WARN_IF(child == nullptr, "Node::addChild NULL pointer exception."); | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (child) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 		ASSERT(child->m_pParent == nullptr, "Node already added. It can't be added again!"); | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 		for (Node * parent = this; parent != nullptr; parent = parent->getParent()) | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 			ASSERT(child != parent, "A Node cannot be the child of his own children!"); | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 		m_vChildren.push_back(child); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		child->setOrder(order); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		child->retain(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 		child->m_pParent = this; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 		if (this->m_pParentScene) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			child->_setParentScene(this->m_pParentScene); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		if (this->m_bDisplayedInScene) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			child->_onEnter(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>ӽڵ<D3BD><EFBFBD><CDB8><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | 		child->_updateOpacity(); | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 		// <20><><EFBFBD>½ڵ<C2BD>ת<EFBFBD><D7AA>
 | 
					
						
							|  |  |  |  | 		child->m_bTransformNeeded = true; | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>ӽڵ<D3BD><DAB5><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 		m_bSortChildrenNeeded = true; | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | #ifdef HIGHER_THAN_VS2012
 | 
					
						
							| 
									
										
										
										
											2018-04-01 13:16:07 +08:00
										 |  |  |  | void e2d::Node::addChild(const InitList<Node*>& vNodes, int order) | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	for (const auto &node : vNodes) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		this->addChild(node, order); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-04-01 13:16:07 +08:00
										 |  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::Node * e2d::Node::getParent() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	return m_pParent; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::Scene * e2d::Node::getParentScene() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	return m_pParentScene; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 13:28:21 +08:00
										 |  |  |  | std::vector<e2d::Node*> e2d::Node::getChildren(String name) const | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 	std::vector<Node*> vChildren; | 
					
						
							| 
									
										
										
										
											2018-03-01 23:47:42 +08:00
										 |  |  |  | 	unsigned int hash = name.getHashCode(); | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto child : m_vChildren) | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// <20><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD><C6BF>ܻ<EFBFBD><DCBB><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC> Hash ֵ<><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱȽ<C8B1> Hash <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 		if (child->m_nHashName == hash && child->m_sName == name) | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			vChildren.push_back(child); | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 	return std::move(vChildren); | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 13:28:21 +08:00
										 |  |  |  | e2d::Node * e2d::Node::getChild(String name) const | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	unsigned int hash = name.getHashCode(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto child : m_vChildren) | 
					
						
							| 
									
										
										
										
											2018-04-24 13:28:21 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// <20><>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>ƿ<EFBFBD><C6BF>ܻ<EFBFBD><DCBB><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC> Hash ֵ<><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȱȽ<C8B1> Hash <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD>
 | 
					
						
							|  |  |  |  | 		if (child->m_nHashName == hash && child->m_sName == name) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			return child; | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	return nullptr; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | std::vector<e2d::Node*> e2d::Node::getAllChildren() const | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 	return m_vChildren; | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | int e2d::Node::getChildrenCount() const | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	return static_cast<int>(m_vChildren.size()); | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::removeFromParent() | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	if (m_pParent) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2017-10-31 17:19:13 +08:00
										 |  |  |  | 		m_pParent->removeChild(this); | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | bool e2d::Node::removeChild(Node * child) | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 	WARN_IF(child == nullptr, "Node::removeChildren NULL pointer exception."); | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (m_vChildren.empty()) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 		return false; | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (child) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2017-12-15 23:15:06 +08:00
										 |  |  |  | 		size_t size = m_vChildren.size(); | 
					
						
							|  |  |  |  | 		for (size_t i = 0; i < size; i++) | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			if (m_vChildren[i] == child) | 
					
						
							|  |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				m_vChildren.erase(m_vChildren.begin() + i); | 
					
						
							|  |  |  |  | 				child->m_pParent = nullptr; | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 				if (child->m_pParentScene) | 
					
						
							|  |  |  |  | 				{ | 
					
						
							|  |  |  |  | 					child->_setParentScene(nullptr); | 
					
						
							|  |  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 				if (child->m_bDisplayedInScene) | 
					
						
							|  |  |  |  | 				{ | 
					
						
							|  |  |  |  | 					child->_onExit(); | 
					
						
							|  |  |  |  | 				} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 				child->release(); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 				return true; | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	return false; | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-30 01:41:29 +08:00
										 |  |  |  | void e2d::Node::removeChildren(String childName) | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 	WARN_IF(childName.isEmpty(), "Invalid Node name."); | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (m_vChildren.empty()) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		return; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Hash ֵ
 | 
					
						
							| 
									
										
										
										
											2018-03-01 23:47:42 +08:00
										 |  |  |  | 	unsigned int hash = childName.getHashCode(); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-15 23:15:06 +08:00
										 |  |  |  | 	size_t size = m_vChildren.size(); | 
					
						
							|  |  |  |  | 	for (size_t i = 0; i < size; i++) | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		auto child = m_vChildren[i]; | 
					
						
							|  |  |  |  | 		if (child->m_nHashName == hash && child->m_sName == childName) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			m_vChildren.erase(m_vChildren.begin() + i); | 
					
						
							|  |  |  |  | 			child->m_pParent = nullptr; | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 			if (child->m_pParentScene) | 
					
						
							|  |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				child->_setParentScene(nullptr); | 
					
						
							|  |  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 			if (child->m_bDisplayedInScene) | 
					
						
							|  |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				child->_onExit(); | 
					
						
							|  |  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 			child->release(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::clearAllChildren() | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	// <20><><EFBFBD>нڵ<D0BD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD>һ
 | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto child : m_vChildren) | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 		if (child->m_bDisplayedInScene) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			child->_onExit(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		child->release(); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	// <20><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	m_vChildren.clear(); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | void e2d::Node::runAction(ActionBase * action) | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-06 15:34:47 +08:00
										 |  |  |  | 	if (this != action->getTarget()) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		WARN_IF( | 
					
						
							|  |  |  |  | 			nullptr != action->getTarget(), | 
					
						
							|  |  |  |  | 			"The action has already got a target, The clone of the action will be created automatically!" | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		if (nullptr != action->getTarget()) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			action = action->clone(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 		ActionManager::__startAction(action, this); | 
					
						
							| 
									
										
										
										
											2018-02-06 15:34:47 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	else | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-02-06 15:34:47 +08:00
										 |  |  |  | 		action->reset(); | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-30 01:41:29 +08:00
										 |  |  |  | void e2d::Node::resumeAction(String strActionName) | 
					
						
							| 
									
										
										
										
											2017-10-19 12:47:36 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-13 13:13:26 +08:00
										 |  |  |  | 	auto actions = ActionManager::get(strActionName); | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto action : actions) | 
					
						
							| 
									
										
										
										
											2017-10-19 12:47:36 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 		if (action->getTarget() == this) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			action->resume(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-30 01:41:29 +08:00
										 |  |  |  | void e2d::Node::pauseAction(String strActionName) | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-13 13:13:26 +08:00
										 |  |  |  | 	auto actions = ActionManager::get(strActionName); | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto action : actions) | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		if (action->getTarget() == this) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			action->pause(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-30 01:41:29 +08:00
										 |  |  |  | void e2d::Node::stopAction(String strActionName) | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-13 13:13:26 +08:00
										 |  |  |  | 	auto actions = ActionManager::get(strActionName); | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto action : actions) | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		if (action->getTarget() == this) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			action->stop(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | e2d::ActionBase * e2d::Node::getAction(String strActionName) | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-13 13:13:26 +08:00
										 |  |  |  | 	auto actions = ActionManager::get(strActionName); | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto action : actions) | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		if (action->getTarget() == this) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			return action; | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-19 12:47:36 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 	return nullptr; | 
					
						
							| 
									
										
										
										
											2017-10-19 12:47:36 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | std::vector<e2d::ActionBase*> e2d::Node::getActions(String strActionName) | 
					
						
							| 
									
										
										
										
											2017-10-19 12:47:36 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-30 16:49:44 +08:00
										 |  |  |  | 	std::vector<ActionBase*>::iterator iter; | 
					
						
							| 
									
										
										
										
											2018-03-13 13:13:26 +08:00
										 |  |  |  | 	auto actions = ActionManager::get(strActionName); | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 	for (iter = actions.begin(); iter != actions.end();) | 
					
						
							| 
									
										
										
										
											2017-10-19 12:47:36 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 		if ((*iter)->getTarget() != this) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			iter = actions.erase(iter); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		else | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			iter++; | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-19 12:47:36 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 	return std::move(actions); | 
					
						
							| 
									
										
										
										
											2017-10-19 12:47:36 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-07 20:14:58 +08:00
										 |  |  |  | bool e2d::Node::isPointIn(Point point) const | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-07 20:14:58 +08:00
										 |  |  |  | 	BOOL ret = 0; | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD>壬<EFBFBD><E5A3AC><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2><EFBFBD>ж<EFBFBD>
 | 
					
						
							|  |  |  |  | 	if (m_pCollider) | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		m_pCollider->getD2dGeometry()->FillContainsPoint( | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 			D2D1::Point2F( | 
					
						
							|  |  |  |  | 				static_cast<float>(point.x), | 
					
						
							|  |  |  |  | 				static_cast<float>(point.y)), | 
					
						
							|  |  |  |  | 			m_MatriFinal, | 
					
						
							|  |  |  |  | 			&ret | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	else | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		// Ϊ<>ڵ㴴<DAB5><E3B4B4>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ײ<EFBFBD><D7B2>
 | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 		ID2D1RectangleGeometry * rect; | 
					
						
							|  |  |  |  | 		Renderer::getID2D1Factory()->CreateRectangleGeometry( | 
					
						
							|  |  |  |  | 			D2D1::RectF(0, 0, m_fWidth, m_fHeight), | 
					
						
							|  |  |  |  | 			&rect | 
					
						
							|  |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		// <20>жϵ<D0B6><CFB5>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 		rect->FillContainsPoint( | 
					
						
							|  |  |  |  | 			D2D1::Point2F( | 
					
						
							|  |  |  |  | 				static_cast<float>(point.x), | 
					
						
							|  |  |  |  | 				static_cast<float>(point.y)), | 
					
						
							|  |  |  |  | 			m_MatriFinal, | 
					
						
							|  |  |  |  | 			&ret | 
					
						
							|  |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		// ɾ<><C9BE><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2>
 | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 		SafeReleaseInterface(&rect); | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-07 20:14:58 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 	if (ret) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		return true; | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	return false; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | bool e2d::Node::isIntersectWith(const Node * pNode) const | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD>壬<EFBFBD><E5A3AC><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2><EFBFBD>ж<EFBFBD>
 | 
					
						
							|  |  |  |  | 	if (this->m_pCollider && pNode->m_pCollider) | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-24 21:22:34 +08:00
										 |  |  |  | 		Relation relation = this->m_pCollider->getRelationWith(pNode->m_pCollider); | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 		if ((relation != Relation::UNKNOWN) &&  | 
					
						
							|  |  |  |  | 			(relation != Relation::DISJOINT)) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			return true; | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 	else | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		// Ϊ<>ڵ㴴<DAB5><E3B4B4>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>ײ<EFBFBD><D7B2>
 | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 		ID2D1RectangleGeometry * pRect1; | 
					
						
							|  |  |  |  | 		ID2D1RectangleGeometry * pRect2; | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		ID2D1TransformedGeometry * pCollider; | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 		D2D1_GEOMETRY_RELATION relation; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сλ<D0A1>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 		Renderer::getID2D1Factory()->CreateRectangleGeometry( | 
					
						
							|  |  |  |  | 			D2D1::RectF(0, 0, m_fWidth, m_fHeight), | 
					
						
							|  |  |  |  | 			&pRect1 | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD>ݶ<EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
 | 
					
						
							|  |  |  |  | 		Renderer::getID2D1Factory()->CreateTransformedGeometry( | 
					
						
							|  |  |  |  | 			pRect1, | 
					
						
							|  |  |  |  | 			m_MatriFinal, | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 			&pCollider | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 		); | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȽϽڵ<CFBD><DAB5>Ĵ<EFBFBD>Сλ<D0A1>ô<EFBFBD><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 		Renderer::getID2D1Factory()->CreateRectangleGeometry( | 
					
						
							|  |  |  |  | 			D2D1::RectF(0, 0, pNode->m_fWidth, pNode->m_fHeight), | 
					
						
							|  |  |  |  | 			&pRect2 | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 		// <20><>ȡ<EFBFBD>ཻ״̬
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		pCollider->CompareWithGeometry( | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 			pRect2, | 
					
						
							|  |  |  |  | 			pNode->m_MatriFinal, | 
					
						
							|  |  |  |  | 			&relation | 
					
						
							|  |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		// ɾ<><C9BE><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2>
 | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 		SafeReleaseInterface(&pRect1); | 
					
						
							|  |  |  |  | 		SafeReleaseInterface(&pRect2); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 		SafeReleaseInterface(&pCollider); | 
					
						
							| 
									
										
										
										
											2018-04-01 23:08:11 +08:00
										 |  |  |  | 		if ((relation != D2D1_GEOMETRY_RELATION_UNKNOWN) && | 
					
						
							|  |  |  |  | 			(relation != D2D1_GEOMETRY_RELATION_DISJOINT)) | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			return true; | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 	return false; | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::setAutoUpdate(bool bAutoUpdate) | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	m_bAutoUpdate = bAutoUpdate; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | void e2d::Node::setDefaultPiovt(double defaultPiovtX, double defaultPiovtY) | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-27 21:07:43 +08:00
										 |  |  |  | 	s_fDefaultPiovtX = min(max(static_cast<float>(defaultPiovtX), 0), 1); | 
					
						
							|  |  |  |  | 	s_fDefaultPiovtY = min(max(static_cast<float>(defaultPiovtY), 0), 1); | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | void e2d::Node::setDefaultColliderEnable(bool bEnable) | 
					
						
							| 
									
										
										
										
											2018-03-07 20:14:58 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  |  | 	s_fDefaultColliderEnabled = bEnable; | 
					
						
							| 
									
										
										
										
											2018-03-07 20:14:58 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-21 18:22:01 +08:00
										 |  |  |  | void e2d::Node::destroy() | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	ActionManager::__clearAllBindedWith(this); | 
					
						
							|  |  |  |  | 	ColliderManager::__removeCollider(m_pCollider); | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto child : m_vChildren) | 
					
						
							| 
									
										
										
										
											2018-04-21 18:22:01 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		SafeRelease(&child); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::resumeAllActions() | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 	ActionManager::__resumeAllBindedWith(this); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::pauseAllActions() | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 	ActionManager::__pauseAllBindedWith(this); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::stopAllActions() | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 	ActionManager::__stopAllBindedWith(this); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::setVisiable(bool value) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	m_bVisiable = value; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-30 01:41:29 +08:00
										 |  |  |  | void e2d::Node::setName(String name) | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | 	WARN_IF(name.isEmpty(), "Invalid Node name."); | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 	if (!name.isEmpty() && m_sName != name) | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>
 | 
					
						
							|  |  |  |  | 		m_sName = name; | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD> Hash <20><>
 | 
					
						
							| 
									
										
										
										
											2018-03-01 23:47:42 +08:00
										 |  |  |  | 		m_nHashName = name.getHashCode(); | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::_setParentScene(Scene * scene) | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	m_pParentScene = scene; | 
					
						
							| 
									
										
										
										
											2018-04-24 20:22:41 +08:00
										 |  |  |  | 	for (auto child : m_vChildren) | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 		child->_setParentScene(scene); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } |