| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  | #include "..\e2dtransition.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-06 23:26:32 +08:00
										 |  |  | #include "..\e2dobject.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-05 13:17:07 +08:00
										 |  |  | #include "..\e2dmodule.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-10 15:28:19 +08:00
										 |  |  | e2d::MoveTransition::MoveTransition(float duration, Direction direction) | 
					
						
							|  |  |  | 	: Transition(duration) | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | 	, direction_(direction) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-10 15:28:19 +08:00
										 |  |  | bool e2d::MoveTransition::Init(Scene * prev, Scene * next) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-09-10 15:28:19 +08:00
										 |  |  | 	if (Transition::Init(prev, next)) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | 		auto size = Window::GetInstance()->GetSize(); | 
					
						
							|  |  |  | 		if (direction_ == Direction::Up) | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | 			pos_delta_ = Point(0, -size.height); | 
					
						
							|  |  |  | 			start_pos_ = Point(0, size.height); | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | 		else if (direction_ == Direction::Down) | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | 			pos_delta_ = Point(0, size.height); | 
					
						
							|  |  |  | 			start_pos_ = Point(0, -size.height); | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | 		else if (direction_ == Direction::Left) | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | 			pos_delta_ = Point(-size.width, 0); | 
					
						
							|  |  |  | 			start_pos_ = Point(size.width, 0); | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | 		else if (direction_ == Direction::Right) | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | 			pos_delta_ = Point(size.width, 0); | 
					
						
							|  |  |  | 			start_pos_ = Point(-size.width, 0); | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 23:26:32 +08:00
										 |  |  | 		if (out_scene_ && out_scene_->GetRoot()) out_scene_->GetRoot()->SetPos(0, 0); | 
					
						
							|  |  |  | 		if (in_scene_->GetRoot()) in_scene_->GetRoot()->SetPos(start_pos_); | 
					
						
							| 
									
										
										
										
											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-09-04 22:42:34 +08:00
										 |  |  | void e2d::MoveTransition::Update() | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | 	Transition::Update(); | 
					
						
							| 
									
										
										
										
											2018-08-02 00:27:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 23:26:32 +08:00
										 |  |  | 	if (out_scene_ && out_scene_->GetRoot()) | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-09-06 23:26:32 +08:00
										 |  |  | 		out_scene_->GetRoot()->SetPos(pos_delta_ * delta_); | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-09-06 23:26:32 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (in_scene_->GetRoot()) | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-09-06 23:26:32 +08:00
										 |  |  | 		in_scene_->GetRoot()->SetPos(start_pos_ + pos_delta_ * delta_); | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | 	if (delta_ >= 1) | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | 		this->Stop(); | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-04 22:42:34 +08:00
										 |  |  | void e2d::MoveTransition::Reset() | 
					
						
							| 
									
										
										
										
											2017-12-09 15:27:11 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-09-06 23:26:32 +08:00
										 |  |  | 	if (out_scene_ && out_scene_->GetRoot()) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		out_scene_->GetRoot()->SetPos(0, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	if (in_scene_->GetRoot()) | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		in_scene_->GetRoot()->SetPos(0, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | } |