| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  | #include "..\e2dtransition.h"
 | 
					
						
							|  |  |  | #include "..\e2dnode.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-22 22:29:42 +08:00
										 |  |  | e2d::MoveTransition::MoveTransition(double duration, Direction direction) | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	: Transition(duration) | 
					
						
							|  |  |  | 	, _direction(direction) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-22 22:29:42 +08:00
										 |  |  | void e2d::MoveTransition::_init(Scene * prev, Scene * next) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	Transition::_init(prev, next); | 
					
						
							| 
									
										
										
										
											2018-04-17 01:11:56 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	double width = _windowSize.width; | 
					
						
							|  |  |  | 	double height = _windowSize.height; | 
					
						
							| 
									
										
										
										
											2018-05-24 20:37:34 +08:00
										 |  |  | 	if (_direction == Direction::Up) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-02 23:13:49 +08:00
										 |  |  | 		_posDelta = Vector2(0, -height); | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 		_startPos = Point(0, height); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-24 20:37:34 +08:00
										 |  |  | 	else if (_direction == Direction::Down) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-02 23:13:49 +08:00
										 |  |  | 		_posDelta = Vector2(0, height); | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 		_startPos = Point(0, -height); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-24 20:37:34 +08:00
										 |  |  | 	else if (_direction == Direction::Left) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-02 23:13:49 +08:00
										 |  |  | 		_posDelta = Vector2(-width, 0); | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 		_startPos = Point(width, 0); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-24 20:37:34 +08:00
										 |  |  | 	else if (_direction == Direction::Right) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-07-02 23:13:49 +08:00
										 |  |  | 		_posDelta = Vector2(width, 0); | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 		_startPos = Point(-width, 0); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	if (_outScene) _outScene->getRoot()->setPos(0, 0); | 
					
						
							|  |  |  | 	_inScene->getRoot()->setPos(_startPos); | 
					
						
							| 
									
										
										
										
											2017-12-09 15:27:11 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-22 22:29:42 +08:00
										 |  |  | void e2d::MoveTransition::_updateCustom() | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	if (_outScene) | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 		_outScene->getRoot()->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-05-09 00:34:15 +08:00
										 |  |  | 		_inScene->getRoot()->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
										 |  |  | 	{ | 
					
						
							|  |  |  | 		this->_stop(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-22 22:29:42 +08:00
										 |  |  | void e2d::MoveTransition::_reset() | 
					
						
							| 
									
										
										
										
											2017-12-09 15:27:11 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	if (_outScene) _outScene->getRoot()->setPos(0, 0); | 
					
						
							|  |  |  | 	_inScene->getRoot()->setPos(0, 0); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-12-09 15:27:11 +08:00
										 |  |  | 
 |