| 
									
										
										
										
											2018-04-21 21:24:46 +08:00
										 |  |  | #include "..\e2dtransition.h"
 | 
					
						
							|  |  |  | #include "..\e2dnode.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-20 00:59:26 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 01:11:56 +08:00
										 |  |  | e2d::TransitionFade::TransitionFade(double duration) | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	: Transition(0) | 
					
						
							|  |  |  | 	, _fadeOutDuration(max(duration / 2, 0)) | 
					
						
							|  |  |  | 	, _fadeInDuration(max(duration / 2, 0)) | 
					
						
							|  |  |  | 	, _fadeOutTransioning(true) | 
					
						
							| 
									
										
										
										
											2017-10-20 00:59:26 +08:00
										 |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 01:11:56 +08:00
										 |  |  | e2d::TransitionFade::TransitionFade(double fadeOutDuration, double fadeInDuration) | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	: Transition(0) | 
					
						
							|  |  |  | 	, _fadeOutDuration(max(fadeOutDuration, 0)) | 
					
						
							|  |  |  | 	, _fadeInDuration(max(fadeInDuration, 0)) | 
					
						
							|  |  |  | 	, _fadeOutTransioning(true) | 
					
						
							| 
									
										
										
										
											2017-10-20 00:59:26 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-17 01:11:56 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-17 12:22:52 +08:00
										 |  |  | e2d::TransitionFade * e2d::TransitionFade::create(double duration) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-19 01:10:37 +08:00
										 |  |  | 	return GC::create<TransitionFade>(duration); | 
					
						
							| 
									
										
										
										
											2018-05-17 12:22:52 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | e2d::TransitionFade * e2d::TransitionFade::create(double fadeOutDuration, double fadeInDuration) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-19 01:10:37 +08:00
										 |  |  | 	return GC::create<TransitionFade>(fadeOutDuration, fadeInDuration); | 
					
						
							| 
									
										
										
										
											2018-05-17 12:22:52 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | void e2d::TransitionFade::_init(Scene * prev, Scene * next) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	Transition::_init(prev, next); | 
					
						
							|  |  |  | 	if (_outScene) | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 		_fadeOutTransioning = true; | 
					
						
							|  |  |  | 		_duration = _fadeOutDuration; | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 		_fadeOutTransioning = false; | 
					
						
							|  |  |  | 		_duration = _fadeInDuration; | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	_outLayerParam.opacity = 1; | 
					
						
							|  |  |  | 	_inLayerParam.opacity = 0; | 
					
						
							| 
									
										
										
										
											2018-04-17 11:41:33 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-17 01:11:56 +08:00
										 |  |  | void e2d::TransitionFade::_updateCustom() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 	if (_fadeOutTransioning) | 
					
						
							| 
									
										
										
										
											2017-10-20 00:59:26 +08:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 		_outLayerParam.opacity = float(1 - _delta); | 
					
						
							| 
									
										
										
										
											2018-05-08 20:03:29 +08:00
										 |  |  | 		if (_delta >= 1) | 
					
						
							| 
									
										
										
										
											2017-12-09 15:27:11 +08:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 			_fadeOutTransioning = false; | 
					
						
							|  |  |  | 			_duration = _fadeInDuration; | 
					
						
							|  |  |  | 			_last = Time::getTotalTime(); | 
					
						
							| 
									
										
										
										
											2017-12-09 15:27:11 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2018-05-09 00:34:15 +08:00
										 |  |  | 		_inLayerParam.opacity = float(_delta); | 
					
						
							| 
									
										
										
										
											2018-05-08 20:03:29 +08:00
										 |  |  | 		if (_delta >= 1) | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  | 			this->_stop(); | 
					
						
							| 
									
										
										
										
											2017-10-21 19:09:31 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-12-09 15:27:11 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-07 16:37:12 +08:00
										 |  |  | void e2d::TransitionFade::_reset() | 
					
						
							| 
									
										
										
										
											2017-12-09 15:27:11 +08:00
										 |  |  | { | 
					
						
							|  |  |  | } |