| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | #include "..\easy2d.h"
 | 
					
						
							| 
									
										
										
										
											2017-10-10 01:14:03 +08:00
										 |  |  |  | #include "..\Win\winbase.h"
 | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | Animation::Animation(float duration) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	m_nDuration = 0; | 
					
						
							|  |  |  |  | 	m_nTotalDuration = UINT(duration * 1000); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | Animation::~Animation() | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-30 16:18:45 +08:00
										 |  |  |  | bool Animation::_isEnd() const | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	return m_nDuration >= m_nTotalDuration; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | void Animation::_init() | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-08 13:26:42 +08:00
										 |  |  |  | 	Action::_init(); | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | 	// <20><>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>
 | 
					
						
							| 
									
										
										
										
											2017-10-10 01:14:03 +08:00
										 |  |  |  | 	m_nLast = steady_clock::now(); | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-10 01:14:03 +08:00
										 |  |  |  | bool Animation::_isDelayEnough(steady_clock::time_point nNow) | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  | 	// <20>ж<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>㹻
 | 
					
						
							| 
									
										
										
										
											2017-10-10 01:14:03 +08:00
										 |  |  |  | 	if (duration_cast<milliseconds>(nNow - m_nLast).count() > m_nAnimationInterval) | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2017-10-10 01:14:03 +08:00
										 |  |  |  | 		// <20><><EFBFBD>¼<EFBFBD>¼ʱ<C2BC><CAB1>
 | 
					
						
							|  |  |  |  | 		m_nLast += milliseconds(m_nAnimationInterval); | 
					
						
							|  |  |  |  | 		m_nDuration += m_nAnimationInterval; | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | 		return true; | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	return false; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void Animation::_reset() | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-08 12:30:45 +08:00
										 |  |  |  | 	Action::_reset(); | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | 	m_nDuration = 0; | 
					
						
							| 
									
										
										
										
											2017-10-10 01:14:03 +08:00
										 |  |  |  | 	// <20><>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>
 | 
					
						
							|  |  |  |  | 	m_nLast = steady_clock::now(); | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | } |