| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  | #include "..\e2dtransition.h"
 | 
					
						
							|  |  |  | #include "..\e2dnode.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-14 00:26:20 +08:00
										 |  |  | e2d::MoveTransition::MoveTransition(Scene* scene, float duration, Direction direction) | 
					
						
							|  |  |  | 	: Transition(scene, duration) | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	, _direction(direction) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-19 15:11:20 +08:00
										 |  |  | bool e2d::MoveTransition::_init(Game * game, Scene * prev) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-08-19 15:11:20 +08:00
										 |  |  | 	if (Transition::_init(game, prev)) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-08-28 00:06:10 +08:00
										 |  |  | 		auto size = Window::getInstance()->getSize(); | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		if (_direction == Direction::Up) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-08-28 00:06:10 +08:00
										 |  |  | 			_posDelta = Vector2(0, -size.height); | 
					
						
							|  |  |  | 			_startPos = Point(0, size.height); | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else if (_direction == Direction::Down) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-08-28 00:06:10 +08:00
										 |  |  | 			_posDelta = Vector2(0, size.height); | 
					
						
							|  |  |  | 			_startPos = Point(0, -size.height); | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else if (_direction == Direction::Left) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-08-28 00:06:10 +08:00
										 |  |  | 			_posDelta = Vector2(-size.width, 0); | 
					
						
							|  |  |  | 			_startPos = Point(size.width, 0); | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else if (_direction == Direction::Right) | 
					
						
							|  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-08-28 00:06:10 +08:00
										 |  |  | 			_posDelta = Vector2(size.width, 0); | 
					
						
							|  |  |  | 			_startPos = Point(-size.width, 0); | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  | 		if (_outScene) _outScene->setPos(0, 0); | 
					
						
							|  |  |  | 		_inScene->setPos(_startPos); | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return false; | 
					
						
							| 
									
										
										
										
											2017-12-09 15:27:11 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-14 00:26:20 +08:00
										 |  |  | void e2d::MoveTransition::_update() | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-08-14 00:26:20 +08:00
										 |  |  | 	Transition::_update(); | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	if (_outScene) | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  | 		_outScene->setPos(_posDelta * _delta); | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	if (_inScene) | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  | 		_inScene->setPos(_startPos + _posDelta * _delta); | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-08 20:03:29 +08:00
										 |  |  | 	if (_delta >= 1) | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-08-14 00:26:20 +08:00
										 |  |  | 		this->_stop(); | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-14 00:26:20 +08:00
										 |  |  | void e2d::MoveTransition::_reset() | 
					
						
							| 
									
										
										
										
											2017-12-09 15:27:11 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-08-23 16:37:51 +08:00
										 |  |  | 	if (_outScene) _outScene->setPos(0, 0); | 
					
						
							|  |  |  | 	_inScene->setPos(0, 0); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | } |