| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  |  | #include "..\e2dnode.h"
 | 
					
						
							| 
									
										
										
										
											2018-08-14 00:41:59 +08:00
										 |  |  |  | #include "..\e2devent.h"
 | 
					
						
							| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  |  | #include "..\e2dmanager.h"
 | 
					
						
							|  |  |  |  | #include "..\e2daction.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-10 00:30:17 +08:00
										 |  |  |  | const e2d::Node::Property e2d::Node::Property::Origin = { 0 }; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | e2d::Node::Property e2d::Node::Property::operator+(Property const & prop) const | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	Property result; | 
					
						
							|  |  |  |  | 	result.posX = this->posX + prop.posX; | 
					
						
							|  |  |  |  | 	result.posY = this->posY + prop.posY; | 
					
						
							|  |  |  |  | 	result.width = this->width + prop.width; | 
					
						
							|  |  |  |  | 	result.height = this->height + prop.height; | 
					
						
							|  |  |  |  | 	result.pivotX = this->pivotX + prop.pivotX; | 
					
						
							|  |  |  |  | 	result.pivotY = this->pivotY + prop.pivotY; | 
					
						
							|  |  |  |  | 	result.scaleX = this->scaleX + prop.scaleX; | 
					
						
							|  |  |  |  | 	result.scaleY = this->scaleY + prop.scaleY; | 
					
						
							|  |  |  |  | 	result.rotation = this->rotation + prop.rotation; | 
					
						
							|  |  |  |  | 	result.skewAngleX = this->skewAngleX + prop.skewAngleX; | 
					
						
							|  |  |  |  | 	result.skewAngleY = this->skewAngleY + prop.skewAngleY; | 
					
						
							|  |  |  |  | 	return std::move(result); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | e2d::Node::Property e2d::Node::Property::operator-(Property const & prop) const | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	Property result; | 
					
						
							|  |  |  |  | 	result.posX = this->posX - prop.posX; | 
					
						
							|  |  |  |  | 	result.posY = this->posY - prop.posY; | 
					
						
							|  |  |  |  | 	result.width = this->width - prop.width; | 
					
						
							|  |  |  |  | 	result.height = this->height - prop.height; | 
					
						
							|  |  |  |  | 	result.pivotX = this->pivotX - prop.pivotX; | 
					
						
							|  |  |  |  | 	result.pivotY = this->pivotY - prop.pivotY; | 
					
						
							|  |  |  |  | 	result.scaleX = this->scaleX - prop.scaleX; | 
					
						
							|  |  |  |  | 	result.scaleY = this->scaleY - prop.scaleY; | 
					
						
							|  |  |  |  | 	result.rotation = this->rotation - prop.rotation; | 
					
						
							|  |  |  |  | 	result.skewAngleX = this->skewAngleX - prop.skewAngleX; | 
					
						
							|  |  |  |  | 	result.skewAngleY = this->skewAngleY - prop.skewAngleY; | 
					
						
							|  |  |  |  | 	return std::move(result); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::Node::Node() | 
					
						
							| 
									
										
										
										
											2018-07-10 00:30:17 +08:00
										 |  |  |  | 	: _order(0) | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	, _posX(0) | 
					
						
							|  |  |  |  | 	, _posY(0) | 
					
						
							|  |  |  |  | 	, _width(0) | 
					
						
							|  |  |  |  | 	, _height(0) | 
					
						
							|  |  |  |  | 	, _scaleX(1.0f) | 
					
						
							|  |  |  |  | 	, _scaleY(1.0f) | 
					
						
							|  |  |  |  | 	, _rotation(0) | 
					
						
							|  |  |  |  | 	, _skewAngleX(0) | 
					
						
							|  |  |  |  | 	, _skewAngleY(0) | 
					
						
							| 
									
										
										
										
											2018-07-04 17:00:21 +08:00
										 |  |  |  | 	, _displayOpacity(1.f) | 
					
						
							|  |  |  |  | 	, _realOpacity(1.f) | 
					
						
							|  |  |  |  | 	, _pivotX(0.f) | 
					
						
							|  |  |  |  | 	, _pivotY(0.f) | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	, _initialMatri(D2D1::Matrix3x2F::Identity()) | 
					
						
							|  |  |  |  | 	, _finalMatri(D2D1::Matrix3x2F::Identity()) | 
					
						
							| 
									
										
										
										
											2018-07-07 01:48:39 +08:00
										 |  |  |  | 	, _visible(true) | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	, _parent(nullptr) | 
					
						
							|  |  |  |  | 	, _parentScene(nullptr) | 
					
						
							|  |  |  |  | 	, _hashName(0) | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | 	, _clipEnabled(false) | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	, _needSort(false) | 
					
						
							|  |  |  |  | 	, _needTransform(false) | 
					
						
							|  |  |  |  | 	, _positionFixed(false) | 
					
						
							| 
									
										
										
										
											2018-07-07 18:04:18 +08:00
										 |  |  |  | 	, _collider(this) | 
					
						
							| 
									
										
										
										
											2018-07-10 00:30:17 +08:00
										 |  |  |  | 	, _extrapolate(Property::Origin) | 
					
						
							| 
									
										
										
										
											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-07-07 01:43:41 +08:00
										 |  |  |  | 	ActionManager::getInstance()->clearAllBindedWith(this); | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	for (const auto& child : _children) | 
					
						
							| 
									
										
										
										
											2018-07-07 01:43:41 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-22 21:22:27 +08:00
										 |  |  |  | 		GC::getInstance()->safeRelease(child); | 
					
						
							| 
									
										
										
										
											2018-07-07 01:43:41 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 23:47:10 +08:00
										 |  |  |  | void e2d::Node::visit() | 
					
						
							| 
									
										
										
										
											2017-10-13 11:42:36 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-07 01:48:39 +08:00
										 |  |  |  | 	if (!_visible) | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-13 01:59:04 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	updateTransform(); | 
					
						
							| 
									
										
										
										
											2018-08-13 23:24:08 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-13 01:59:04 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	_extrapolate = this->getProperty(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | 	auto pRT = Renderer::getInstance()->getRenderTarget(); | 
					
						
							|  |  |  |  | 	if (_clipEnabled) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		pRT->SetTransform(_finalMatri); | 
					
						
							|  |  |  |  | 		pRT->PushAxisAlignedClip( | 
					
						
							|  |  |  |  | 			D2D1::RectF(0, 0, _width, _height), | 
					
						
							|  |  |  |  | 			D2D1_ANTIALIAS_MODE_PER_PRIMITIVE | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-01 17:53:56 +08:00
										 |  |  |  | 	if (_children.empty()) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | 		pRT->SetTransform(_finalMatri); | 
					
						
							| 
									
										
										
										
											2018-08-13 23:24:08 +08:00
										 |  |  |  | 		this->draw(); | 
					
						
							| 
									
										
										
										
											2018-06-01 17:53:56 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	else | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-06-01 17:53:56 +08:00
										 |  |  |  | 		// <20>ӽڵ<D3BD><DAB5><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 		_sortChildren(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 		size_t i; | 
					
						
							| 
									
										
										
										
											2018-07-13 00:45:39 +08:00
										 |  |  |  | 		for (i = 0; i < _children.size(); ++i) | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 			auto child = _children[i]; | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 			// <20><><EFBFBD><EFBFBD> Order С<><D0A1><EFBFBD><EFBFBD><EFBFBD>Ľڵ<C4BD>
 | 
					
						
							|  |  |  |  | 			if (child->getOrder() < 0) | 
					
						
							|  |  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2018-08-13 23:47:10 +08:00
										 |  |  |  | 				child->visit(); | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 			else | 
					
						
							|  |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				break; | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | 		pRT->SetTransform(_finalMatri); | 
					
						
							| 
									
										
										
										
											2018-08-13 23:24:08 +08:00
										 |  |  |  | 		this->draw(); | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD>ڵ<EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-07-13 00:45:39 +08:00
										 |  |  |  | 		for (; i < _children.size(); ++i) | 
					
						
							| 
									
										
										
										
											2018-08-13 23:47:10 +08:00
										 |  |  |  | 			_children[i]->visit(); | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (_clipEnabled) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		pRT->PopAxisAlignedClip(); | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-07 18:04:18 +08:00
										 |  |  |  | void e2d::Node::_renderOutline() | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | 	if (_visible) | 
					
						
							| 
									
										
										
										
											2018-07-07 18:04:18 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-29 13:44:53 +08:00
										 |  |  |  | 		auto renderer = Renderer::getInstance(); | 
					
						
							|  |  |  |  | 		renderer->getRenderTarget()->SetTransform(_finalMatri); | 
					
						
							|  |  |  |  | 		renderer->getRenderTarget()->DrawRectangle( | 
					
						
							|  |  |  |  | 			D2D1::RectF(0, 0, _width, _height), | 
					
						
							|  |  |  |  | 			renderer->getSolidColorBrush(), | 
					
						
							|  |  |  |  | 			1.5f | 
					
						
							|  |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2018-07-07 18:04:18 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | 		// <20><>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD>ӽڵ<D3BD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 		for (const auto& child : _children) | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			child->_renderOutline(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-07-07 18:04:18 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-07 15:12:18 +08:00
										 |  |  |  | void e2d::Node::_renderCollider() | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-24 00:24:29 +08:00
										 |  |  |  | 	if (_visible) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		_collider.render(); | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽڵ<D3BD><DAB5>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2>
 | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 		for (const auto& child : _children) | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			child->_renderCollider(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-29 23:48:32 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-13 00:45:39 +08:00
										 |  |  |  | void e2d::Node::updateTransform() | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-06-01 17:53:56 +08:00
										 |  |  |  | 	if (!_needTransform) | 
					
						
							|  |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-13 01:59:04 +08:00
										 |  |  |  | 	_needTransform = false; | 
					
						
							| 
									
										
										
										
											2018-07-13 00:45:39 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-13 01:59:04 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	D2D1_POINT_2F pivot = { _width * _pivotX, _height * _pivotY }; | 
					
						
							|  |  |  |  | 	// <20>任 Initial <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽڵ㽫<DAB5><E3BDAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б任
 | 
					
						
							|  |  |  |  | 	_initialMatri = D2D1::Matrix3x2F::Scale( | 
					
						
							|  |  |  |  | 		_scaleX, | 
					
						
							|  |  |  |  | 		_scaleY, | 
					
						
							|  |  |  |  | 		pivot | 
					
						
							|  |  |  |  | 	) * D2D1::Matrix3x2F::Skew( | 
					
						
							|  |  |  |  | 		_skewAngleX, | 
					
						
							|  |  |  |  | 		_skewAngleY, | 
					
						
							|  |  |  |  | 		pivot | 
					
						
							|  |  |  |  | 	) * D2D1::Matrix3x2F::Rotation( | 
					
						
							|  |  |  |  | 		_rotation, | 
					
						
							|  |  |  |  | 		pivot | 
					
						
							|  |  |  |  | 	) * D2D1::Matrix3x2F::Translation( | 
					
						
							|  |  |  |  | 		_posX, | 
					
						
							|  |  |  |  | 		_posY | 
					
						
							|  |  |  |  | 	); | 
					
						
							|  |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><C4B5>任 Final <20><><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	_finalMatri = _initialMatri * D2D1::Matrix3x2F::Translation(-pivot.x, -pivot.y); | 
					
						
							|  |  |  |  | 	// <20><EFBFBD><CDB8>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	if (!_positionFixed && _parent) | 
					
						
							| 
									
										
										
										
											2018-07-13 00:45:39 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-13 01:59:04 +08:00
										 |  |  |  | 		_initialMatri = _initialMatri * _parent->_initialMatri; | 
					
						
							|  |  |  |  | 		_finalMatri = _finalMatri * _parent->_initialMatri; | 
					
						
							| 
									
										
										
										
											2018-07-13 00:45:39 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// ֪ͨ<CDA8>ӽڵ<D3BD><DAB5><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
 | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	for (const auto& child : _children) | 
					
						
							| 
									
										
										
										
											2018-07-13 00:45:39 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		child->_needTransform = true; | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-08-13 23:24:08 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2>
 | 
					
						
							|  |  |  |  | 	_collider.recreate(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (_collider.isEnabled() && | 
					
						
							|  |  |  |  | 		_collider.isCollisionNotify() && | 
					
						
							|  |  |  |  | 		_collider.getShape() != Collider::Shape::None) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		CollisionManager::getInstance()->__updateCollider(&_collider); | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-13 00:45:39 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 23:24:08 +08:00
										 |  |  |  | bool e2d::Node::dispatch(const MouseEvent & e, bool handled) | 
					
						
							| 
									
										
										
										
											2018-07-16 22:11:27 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	if (_visible) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-08-13 23:24:08 +08:00
										 |  |  |  | 		auto dispatcher = dynamic_cast<EventHandler*>(this); | 
					
						
							|  |  |  |  | 		if (dispatcher) | 
					
						
							|  |  |  |  | 			dispatcher->handle(e); | 
					
						
							| 
									
										
										
										
											2018-08-13 00:10:27 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 23:24:08 +08:00
										 |  |  |  | 		for (auto riter = _children.crbegin(); riter != _children.crend(); ++riter) | 
					
						
							|  |  |  |  | 			handled = (*riter)->dispatch(e, handled); | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 23:24:08 +08:00
										 |  |  |  | 	return handled; | 
					
						
							| 
									
										
										
										
											2018-07-16 22:11:27 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 23:24:08 +08:00
										 |  |  |  | bool e2d::Node::dispatch(const KeyEvent & e, bool handled) | 
					
						
							| 
									
										
										
										
											2018-07-16 22:11:27 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	if (_visible) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-08-13 23:24:08 +08:00
										 |  |  |  | 		auto dispatcher = dynamic_cast<EventHandler*>(this); | 
					
						
							|  |  |  |  | 		if (dispatcher) | 
					
						
							|  |  |  |  | 			dispatcher->handle(e); | 
					
						
							| 
									
										
										
										
											2018-08-12 14:05:12 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 23:24:08 +08:00
										 |  |  |  | 		for (auto riter = _children.crbegin(); riter != _children.crend(); ++riter) | 
					
						
							|  |  |  |  | 			handled = (*riter)->dispatch(e, handled); | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 23:24:08 +08:00
										 |  |  |  | 	return handled; | 
					
						
							| 
									
										
										
										
											2018-07-16 22:11:27 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-01 17:53:56 +08:00
										 |  |  |  | void e2d::Node::_sortChildren() | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	if (_needSort) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-06-01 17:53:56 +08:00
										 |  |  |  | 		std::sort( | 
					
						
							|  |  |  |  | 			std::begin(_children), | 
					
						
							|  |  |  |  | 			std::end(_children), | 
					
						
							|  |  |  |  | 			[](Node * n1, Node * n2) { return n1->getOrder() < n2->getOrder(); } | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		_needSort = false; | 
					
						
							| 
									
										
										
										
											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-05-09 00:34:15 +08:00
										 |  |  |  | 	if (_parent) | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 		_displayOpacity = _realOpacity * _parent->_displayOpacity; | 
					
						
							| 
									
										
										
										
											2018-04-24 10:35:58 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	for (const auto& child : _children) | 
					
						
							| 
									
										
										
										
											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-07-07 01:48:39 +08:00
										 |  |  |  | bool e2d::Node::isVisible() const | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-07 01:48:39 +08:00
										 |  |  |  | 	return _visible; | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::String e2d::Node::getName() const | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 20:03:29 +08:00
										 |  |  |  | 	return _name; | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-16 22:11:27 +08:00
										 |  |  |  | size_t e2d::Node::getHashName() const | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _hashName; | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getPosX() const | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _posX; | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getPosY() const | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _posY; | 
					
						
							| 
									
										
										
										
											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-05-09 00:34:15 +08:00
										 |  |  |  | 	return Point(_posX, _posY); | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getWidth() const | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _width * _scaleX; | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getHeight() const | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _height * _scaleY; | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getRealWidth() const | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _width; | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getRealHeight() const | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _height; | 
					
						
							| 
									
										
										
										
											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-05-09 00:34:15 +08:00
										 |  |  |  | 	return Size(_width, _height); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getPivotX() const | 
					
						
							| 
									
										
										
										
											2017-10-26 17:17:30 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _pivotX; | 
					
						
							| 
									
										
										
										
											2017-10-26 17:17:30 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getPivotY() const | 
					
						
							| 
									
										
										
										
											2017-10-26 17:17:30 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _pivotY; | 
					
						
							| 
									
										
										
										
											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-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getScaleX() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _scaleX; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getScaleY() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _scaleY; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getSkewX() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _skewAngleX; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getSkewY() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _skewAngleY; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getRotation() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _rotation; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | float e2d::Node::getOpacity() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _realOpacity; | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-17 15:22:14 +08:00
										 |  |  |  | e2d::Node::Property e2d::Node::getProperty() const | 
					
						
							| 
									
										
										
										
											2018-04-21 18:42:07 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-17 15:22:14 +08:00
										 |  |  |  | 	Property prop; | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	prop.posX = _posX; | 
					
						
							|  |  |  |  | 	prop.posY = _posY; | 
					
						
							|  |  |  |  | 	prop.width = _width; | 
					
						
							|  |  |  |  | 	prop.height = _height; | 
					
						
							|  |  |  |  | 	prop.pivotX = _pivotX; | 
					
						
							|  |  |  |  | 	prop.pivotY = _pivotY; | 
					
						
							|  |  |  |  | 	prop.scaleX = _scaleX; | 
					
						
							|  |  |  |  | 	prop.scaleY = _scaleY; | 
					
						
							|  |  |  |  | 	prop.rotation = _rotation; | 
					
						
							|  |  |  |  | 	prop.skewAngleX = _skewAngleX; | 
					
						
							|  |  |  |  | 	prop.skewAngleY = _skewAngleY; | 
					
						
							| 
									
										
										
										
											2018-07-10 00:30:17 +08:00
										 |  |  |  | 	return std::move(prop); | 
					
						
							| 
									
										
										
										
											2018-04-21 18:42:07 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-13 00:45:39 +08:00
										 |  |  |  | e2d::Node::Property e2d::Node::getExtrapolate() const | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	return this->getProperty() - _extrapolate; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-07 15:12:18 +08:00
										 |  |  |  | e2d::Collider* e2d::Node::getCollider() | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-07 15:12:18 +08:00
										 |  |  |  | 	return &_collider; | 
					
						
							| 
									
										
										
										
											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
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-10 00:30:17 +08:00
										 |  |  |  | 	return _order; | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::setOrder(int order) | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | 	if (_order == order) | 
					
						
							|  |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-10 00:30:17 +08:00
										 |  |  |  | 	_order = order; | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | 	if (_parent) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		_parent->_needSort = true; | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setPosX(float x) | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	this->setPos(x, _posY); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setPosY(float y) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	this->setPos(_posX, 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-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setPos(float x, float y) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	if (_posX == x && _posY == y) | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | 	_posX = x; | 
					
						
							|  |  |  |  | 	_posY = y; | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	_needTransform = true; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 17:15:57 +08:00
										 |  |  |  | void e2d::Node::setPosFixed(bool fixed) | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	if (_positionFixed == fixed) | 
					
						
							| 
									
										
										
										
											2018-05-07 17:15:57 +08:00
										 |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	_positionFixed = fixed; | 
					
						
							|  |  |  |  | 	_needTransform = true; | 
					
						
							| 
									
										
										
										
											2018-05-07 17:15:57 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::movePosX(float x) | 
					
						
							| 
									
										
										
										
											2017-11-03 12:51:01 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	this->movePos(x, 0); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::movePosY(float y) | 
					
						
							| 
									
										
										
										
											2017-11-03 12:51:01 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	this->movePos(0, y); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::movePos(float x, float y) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	this->setPos(_posX + x, _posY + y); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-02 23:13:49 +08:00
										 |  |  |  | void e2d::Node::movePos(const Vector2 & 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-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setScaleX(float scaleX) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	this->setScale(scaleX, _scaleY); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setScaleY(float scaleY) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	this->setScale(_scaleX, scaleY); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setScale(float 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-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setScale(float scaleX, float scaleY) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	if (_scaleX == scaleX && _scaleY == scaleY) | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | 	_scaleX = scaleX; | 
					
						
							|  |  |  |  | 	_scaleY = scaleY; | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	_needTransform = true; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setSkewX(float angleX) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	this->setSkew(angleX, _skewAngleY); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setSkewY(float angleY) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	this->setSkew(_skewAngleX, angleY); | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setSkew(float angleX, float angleY) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	if (_skewAngleX == angleX && _skewAngleY == angleY) | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | 	_skewAngleX = angleX; | 
					
						
							|  |  |  |  | 	_skewAngleY = angleY; | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	_needTransform = true; | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setRotation(float angle) | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	if (_rotation == angle) | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | 	_rotation = angle; | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	_needTransform = true; | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setOpacity(float opacity) | 
					
						
							| 
									
										
										
										
											2017-10-15 02:46:24 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	if (_realOpacity == opacity) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | 	_displayOpacity = _realOpacity = std::min(std::max(opacity, 0.f), 1.f); | 
					
						
							| 
									
										
										
										
											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-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setPivotX(float pivotX) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	this->setPivot(pivotX, _pivotY); | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setPivotY(float pivotY) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	this->setPivot(_pivotX, pivotY); | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setPivot(float pivotX, float pivotY) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	if (_pivotX == pivotX && _pivotY == pivotY) | 
					
						
							| 
									
										
										
										
											2017-10-15 23:58:39 +08:00
										 |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | 	_pivotX = std::min(std::max(pivotX, 0.f), 1.f); | 
					
						
							|  |  |  |  | 	_pivotY = std::min(std::max(pivotY, 0.f), 1.f); | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	_needTransform = true; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setWidth(float width) | 
					
						
							| 
									
										
										
										
											2018-03-01 19:28:22 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	this->setSize(width, _height); | 
					
						
							| 
									
										
										
										
											2018-03-01 19:28:22 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setHeight(float height) | 
					
						
							| 
									
										
										
										
											2018-03-01 19:28:22 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	this->setSize(_width, height); | 
					
						
							| 
									
										
										
										
											2018-03-01 19:28:22 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | void e2d::Node::setSize(float width, float height) | 
					
						
							| 
									
										
										
										
											2018-03-01 19:28:22 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	if (_width == width && _height == height) | 
					
						
							| 
									
										
										
										
											2018-03-01 19:28:22 +08:00
										 |  |  |  | 		return; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | 	_width = width; | 
					
						
							|  |  |  |  | 	_height = height; | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	_needTransform = true; | 
					
						
							| 
									
										
										
										
											2018-03-01 19:28:22 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void e2d::Node::setSize(Size size) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	this->setSize(size.width, size.height); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-17 15:22:14 +08:00
										 |  |  |  | void e2d::Node::setProperty(Property prop) | 
					
						
							| 
									
										
										
										
											2018-04-21 18:42:07 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	this->setPos(prop.posX, prop.posY); | 
					
						
							|  |  |  |  | 	this->setSize(prop.width, prop.height); | 
					
						
							|  |  |  |  | 	this->setPivot(prop.pivotX, prop.pivotY); | 
					
						
							|  |  |  |  | 	this->setScale(prop.scaleX, prop.scaleY); | 
					
						
							|  |  |  |  | 	this->setRotation(prop.rotation); | 
					
						
							|  |  |  |  | 	this->setSkew(prop.skewAngleX, prop.skewAngleY); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-28 18:44:37 +08:00
										 |  |  |  | void e2d::Node::setClipEnabled(bool enabled) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	_clipEnabled = enabled; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-05-24 00:58:16 +08:00
										 |  |  |  | 		if (child->_parent != nullptr) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-24 12:24:39 +08:00
										 |  |  |  | 			throw Exception(L"<EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><EFBFBD>ڵ<EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>"); | 
					
						
							| 
									
										
										
										
											2018-05-24 00:58:16 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											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-05-24 00:58:16 +08:00
										 |  |  |  | 			if (child == parent) | 
					
						
							|  |  |  |  | 			{ | 
					
						
							| 
									
										
										
										
											2018-05-24 12:24:39 +08:00
										 |  |  |  | 				throw Exception(L"һ<EFBFBD><EFBFBD><EFBFBD>ڵ㲻<EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӽڵ<EFBFBD>"); | 
					
						
							| 
									
										
										
										
											2018-05-24 00:58:16 +08:00
										 |  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-22 21:22:27 +08:00
										 |  |  |  | 		child->retain(); | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 		_children.push_back(child); | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 		child->setOrder(order); | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 		child->_parent = this; | 
					
						
							|  |  |  |  | 		if (this->_parentScene) | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 			child->_setParentScene(this->_parentScene); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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>
 | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 		child->_needTransform = true; | 
					
						
							| 
									
										
										
										
											2017-11-09 18:22:41 +08:00
										 |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>ӽڵ<D3BD><DAB5><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 		_needSort = true; | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 17:02:18 +08:00
										 |  |  |  | void e2d::Node::addChild(const std::vector<Node*>& nodes, int order) | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	for (const auto& node : nodes) | 
					
						
							| 
									
										
										
										
											2018-03-31 18:12:01 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		this->addChild(node, order); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::Node * e2d::Node::getParent() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _parent; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | e2d::Scene * e2d::Node::getParentScene() const | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _parentScene; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  |  | std::vector<e2d::Node*> e2d::Node::getChildren(const String& name) const | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | 	std::vector<Node*> vChildren; | 
					
						
							| 
									
										
										
										
											2018-07-16 22:11:27 +08:00
										 |  |  |  | 	size_t hash = name.getHashCode(); | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	for (const auto& child : _children) | 
					
						
							| 
									
										
										
										
											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-05-09 00:34:15 +08:00
										 |  |  |  | 		if (child->_hashName == hash && child->_name == 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-05-07 15:48:06 +08:00
										 |  |  |  | e2d::Node * e2d::Node::getChild(const String& name) const | 
					
						
							| 
									
										
										
										
											2018-04-24 13:28:21 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-16 22:11:27 +08:00
										 |  |  |  | 	size_t hash = name.getHashCode(); | 
					
						
							| 
									
										
										
										
											2018-04-24 13:28:21 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	for (const auto& child : _children) | 
					
						
							| 
									
										
										
										
											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>
 | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 		if (child->_hashName == hash && child->_name == name) | 
					
						
							| 
									
										
										
										
											2018-04-24 13:28:21 +08:00
										 |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			return child; | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	return nullptr; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 14:16:36 +08:00
										 |  |  |  | const std::vector<e2d::Node*>& e2d::Node::getAllChildren() const | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return _children; | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-11 23:56:40 +08:00
										 |  |  |  | int e2d::Node::getChildrenCount() const | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	return static_cast<int>(_children.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
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	if (_parent) | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 		_parent->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
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	if (_children.empty()) | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 		return false; | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (child) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-21 23:04:58 +08:00
										 |  |  |  | 		auto iter = std::find(_children.begin(), _children.end(), child); | 
					
						
							|  |  |  |  | 		if (iter != _children.end()) | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-21 23:04:58 +08:00
										 |  |  |  | 			_children.erase(iter); | 
					
						
							|  |  |  |  | 			child->_parent = nullptr; | 
					
						
							| 
									
										
										
										
											2018-02-03 22:04:43 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-21 23:04:58 +08:00
										 |  |  |  | 			if (child->_parentScene) | 
					
						
							|  |  |  |  | 			{ | 
					
						
							|  |  |  |  | 				child->_setParentScene(nullptr); | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-05-21 23:04:58 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-22 21:22:27 +08:00
										 |  |  |  | 			child->release(); | 
					
						
							| 
									
										
										
										
											2018-05-21 23:04:58 +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-05-07 15:48:06 +08:00
										 |  |  |  | void e2d::Node::removeChildren(const 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
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	if (_children.empty()) | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		return; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Hash ֵ
 | 
					
						
							| 
									
										
										
										
											2018-07-16 22:11:27 +08:00
										 |  |  |  | 	size_t hash = childName.getHashCode(); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-12 15:38:02 +08:00
										 |  |  |  | 	auto iter = std::find_if( | 
					
						
							|  |  |  |  | 		_children.begin(), | 
					
						
							|  |  |  |  | 		_children.end(), | 
					
						
							|  |  |  |  | 		[childName, hash](Node* child) ->bool { return child->_hashName == hash && child->_name == childName; } | 
					
						
							|  |  |  |  | 	); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (iter != _children.end()) | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-08-12 15:38:02 +08:00
										 |  |  |  | 		(*iter)->_parent = nullptr; | 
					
						
							|  |  |  |  | 		if ((*iter)->_parentScene) | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-08-12 15:38:02 +08:00
										 |  |  |  | 			(*iter)->_setParentScene(nullptr); | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-08-12 15:38:02 +08:00
										 |  |  |  | 		(*iter)->release(); | 
					
						
							|  |  |  |  | 		_children.erase(iter); | 
					
						
							| 
									
										
										
										
											2017-10-14 18:43:32 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-13 00:45:39 +08:00
										 |  |  |  | void e2d::Node::removeAllChildren() | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	// <20><><EFBFBD>нڵ<D0BD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD><EFBFBD>һ
 | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	for (const auto& child : _children) | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-22 21:22:27 +08:00
										 |  |  |  | 		child->release(); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	// <20><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	_children.clear(); | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 20:03:29 +08:00
										 |  |  |  | void e2d::Node::runAction(Action * action) | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-05 01:09:54 +08:00
										 |  |  |  | 	ActionManager::getInstance()->start(action, this, false); | 
					
						
							| 
									
										
										
										
											2017-10-19 00:50:04 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-22 00:11:57 +08:00
										 |  |  |  | void e2d::Node::resumeAction(const String& name) | 
					
						
							| 
									
										
										
										
											2017-10-19 12:47:36 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-05 01:09:54 +08:00
										 |  |  |  | 	auto& actions = ActionManager::getInstance()->get(name); | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	for (const 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-05-22 00:11:57 +08:00
										 |  |  |  | void e2d::Node::pauseAction(const String& name) | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-05 01:09:54 +08:00
										 |  |  |  | 	auto& actions = ActionManager::getInstance()->get(name); | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	for (const auto& action : actions) | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		if (action->getTarget() == this) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			action->pause(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-22 00:11:57 +08:00
										 |  |  |  | void e2d::Node::stopAction(const String& name) | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-05 01:09:54 +08:00
										 |  |  |  | 	auto& actions = ActionManager::getInstance()->get(name); | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	for (const auto& action : actions) | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		if (action->getTarget() == this) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  | 			action->stop(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-07 18:04:18 +08:00
										 |  |  |  | bool e2d::Node::containsPoint(const Point& point) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-29 13:44:53 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-07-13 00:45:39 +08:00
										 |  |  |  | 	updateTransform(); | 
					
						
							| 
									
										
										
										
											2018-07-29 13:44:53 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Ϊ<>ڵ㴴<DAB5><E3B4B4>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	BOOL ret = 0; | 
					
						
							|  |  |  |  | 	ID2D1RectangleGeometry * rectGeo = nullptr; | 
					
						
							|  |  |  |  | 	auto factory = Renderer::getFactory(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	HRESULT hr = factory->CreateRectangleGeometry( | 
					
						
							|  |  |  |  | 		D2D1::RectF(0, 0, _width, _height), | 
					
						
							|  |  |  |  | 		&rectGeo | 
					
						
							|  |  |  |  | 	); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (SUCCEEDED(hr)) | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-29 13:44:53 +08:00
										 |  |  |  | 		rectGeo->FillContainsPoint( | 
					
						
							| 
									
										
										
										
											2018-07-28 20:06:27 +08:00
										 |  |  |  | 			D2D1::Point2F(point.x, point.y), | 
					
						
							| 
									
										
										
										
											2018-07-29 13:44:53 +08:00
										 |  |  |  | 			_finalMatri, | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 			&ret | 
					
						
							|  |  |  |  | 		); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-29 13:44:53 +08:00
										 |  |  |  | 	SafeRelease(rectGeo); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	return ret != 0; | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-07 18:04:18 +08:00
										 |  |  |  | bool e2d::Node::intersects(Node * node) | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-29 13:44:53 +08:00
										 |  |  |  | 	// <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-07-13 00:45:39 +08:00
										 |  |  |  | 	updateTransform(); | 
					
						
							|  |  |  |  | 	node->updateTransform(); | 
					
						
							| 
									
										
										
										
											2018-07-29 13:44:53 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Ϊ<>ڵ㴴<DAB5><E3B4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							|  |  |  |  | 	D2D1_GEOMETRY_RELATION relation = D2D1_GEOMETRY_RELATION_UNKNOWN; | 
					
						
							|  |  |  |  | 	ID2D1RectangleGeometry *rectGeo = nullptr, *rectGeo2 = nullptr; | 
					
						
							|  |  |  |  | 	ID2D1TransformedGeometry *transGeo = nullptr, *transGeo2 = nullptr; | 
					
						
							|  |  |  |  | 	auto factory = Renderer::getFactory(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	HRESULT hr = factory->CreateRectangleGeometry( | 
					
						
							|  |  |  |  | 		D2D1::RectF(0, 0, _width, _height), | 
					
						
							|  |  |  |  | 		&rectGeo | 
					
						
							|  |  |  |  | 	); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (SUCCEEDED(hr)) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		hr = factory->CreateRectangleGeometry( | 
					
						
							|  |  |  |  | 			D2D1::RectF(0, 0, node->_width, node->_height), | 
					
						
							|  |  |  |  | 			&rectGeo2 | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (SUCCEEDED(hr)) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		hr = factory->CreateTransformedGeometry( | 
					
						
							|  |  |  |  | 			rectGeo, | 
					
						
							|  |  |  |  | 			_finalMatri, | 
					
						
							|  |  |  |  | 			&transGeo | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (SUCCEEDED(hr)) | 
					
						
							|  |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		hr = factory->CreateTransformedGeometry( | 
					
						
							|  |  |  |  | 			rectGeo2, | 
					
						
							|  |  |  |  | 			node->_finalMatri, | 
					
						
							|  |  |  |  | 			&transGeo2 | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if (SUCCEEDED(hr)) | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// <20><>ȡ<EFBFBD>ཻ״̬
 | 
					
						
							| 
									
										
										
										
											2018-07-29 13:44:53 +08:00
										 |  |  |  | 		transGeo->CompareWithGeometry( | 
					
						
							|  |  |  |  | 			transGeo2, | 
					
						
							| 
									
										
										
										
											2018-07-07 18:04:18 +08:00
										 |  |  |  | 			D2D1::Matrix3x2F::Identity(), | 
					
						
							| 
									
										
										
										
											2018-03-14 15:33:58 +08:00
										 |  |  |  | 			&relation | 
					
						
							|  |  |  |  | 		); | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-29 13:44:53 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	SafeRelease(rectGeo); | 
					
						
							|  |  |  |  | 	SafeRelease(rectGeo2); | 
					
						
							|  |  |  |  | 	SafeRelease(transGeo); | 
					
						
							|  |  |  |  | 	SafeRelease(transGeo2); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	return relation != D2D1_GEOMETRY_RELATION_UNKNOWN && | 
					
						
							|  |  |  |  | 		relation != D2D1_GEOMETRY_RELATION_DISJOINT; | 
					
						
							| 
									
										
										
										
											2018-03-06 09:56:17 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  |  | void e2d::Node::resumeAllActions() | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-05 01:09:54 +08:00
										 |  |  |  | 	ActionManager::getInstance()->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-07-05 01:09:54 +08:00
										 |  |  |  | 	ActionManager::getInstance()->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-07-05 01:09:54 +08:00
										 |  |  |  | 	ActionManager::getInstance()->stopAllBindedWith(this); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-07 01:48:39 +08:00
										 |  |  |  | void e2d::Node::setVisible(bool value) | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-07 01:48:39 +08:00
										 |  |  |  | 	_visible = value; | 
					
						
							| 
									
										
										
										
											2017-10-12 23:34:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-07 15:48:06 +08:00
										 |  |  |  | void e2d::Node::setName(const 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-05-08 20:03:29 +08:00
										 |  |  |  | 	if (!name.isEmpty() && _name != name) | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2018-05-08 20:03:29 +08:00
										 |  |  |  | 		_name = name; | 
					
						
							| 
									
										
										
										
											2017-10-14 11:40:47 +08:00
										 |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD> Hash <20><>
 | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 		_hashName = 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
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  |  | 	_parentScene = scene; | 
					
						
							| 
									
										
										
										
											2018-08-12 14:30:28 +08:00
										 |  |  |  | 	for (const auto& child : _children) | 
					
						
							| 
									
										
										
										
											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
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | } |