| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  | #include "..\e2dcollider.h"
 | 
					
						
							|  |  |  | #include "..\e2dnode.h"
 | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | e2d::ColliderRect::ColliderRect() | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	: _pD2dRectangle(nullptr) | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | e2d::ColliderRect::ColliderRect(double x, double y, double width, double height) | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	: _pD2dRectangle(nullptr) | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | { | 
					
						
							|  |  |  | 	this->setRect(x, y, x + width, y + height); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | e2d::ColliderRect::ColliderRect(Node * node) | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	: _pD2dRectangle(nullptr) | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | { | 
					
						
							|  |  |  | 	this->setRect(0, 0, node->getRealWidth(), node->getRealHeight()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | e2d::ColliderRect::~ColliderRect() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	SafeReleaseInterface(&_pD2dRectangle); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void e2d::ColliderRect::setRect(double left, double top, double right, double bottom) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	SafeReleaseInterface(&_pD2dRectangle); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	Renderer::getID2D1Factory()->CreateRectangleGeometry( | 
					
						
							|  |  |  | 		D2D1::RectF( | 
					
						
							|  |  |  | 			static_cast<float>(left),  | 
					
						
							|  |  |  | 			static_cast<float>(top),  | 
					
						
							|  |  |  | 			static_cast<float>(right),  | 
					
						
							|  |  |  | 			static_cast<float>(bottom)), | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 		&_pD2dRectangle | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | 	); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void e2d::ColliderRect::_resize() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	if (_pParentNode && _bEnable) | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 		this->setRect( 0, 0, _pParentNode->getRealWidth(), _pParentNode->getRealHeight()); | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ID2D1RectangleGeometry * e2d::ColliderRect::getD2dGeometry() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-08 17:40:36 +08:00
										 |  |  | 	return _pD2dRectangle; | 
					
						
							| 
									
										
										
										
											2018-04-02 23:01:38 +08:00
										 |  |  | } |