40 lines
		
	
	
		
			659 B
		
	
	
	
		
			C++
		
	
	
	
		
		
			
		
	
	
			40 lines
		
	
	
		
			659 B
		
	
	
	
		
			C++
		
	
	
	
|  | #include "..\easy2d.h"
 | |||
|  | #include "..\Win\winbase.h"
 | |||
|  | 
 | |||
|  | ActionDelay::ActionDelay(float duration) | |||
|  | { | |||
|  | 	setInterval(LONGLONG(duration * 1000)); | |||
|  | } | |||
|  | 
 | |||
|  | ActionDelay::~ActionDelay() | |||
|  | { | |||
|  | } | |||
|  | 
 | |||
|  | ActionDelay * ActionDelay::copy() const | |||
|  | { | |||
|  | 	return new ActionDelay(m_nAnimationInterval / 1000.0f); | |||
|  | } | |||
|  | 
 | |||
|  | void ActionDelay::_init() | |||
|  | { | |||
|  | 	Action::_init(); | |||
|  | 	// <20><>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>
 | |||
|  | 	m_nLast = steady_clock::now(); | |||
|  | } | |||
|  | 
 | |||
|  | void ActionDelay::_exec(steady_clock::time_point nNow) | |||
|  | { | |||
|  | 	// <20>ж<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>㹻
 | |||
|  | 	if (duration_cast<milliseconds>(nNow - m_nLast).count() > m_nAnimationInterval) | |||
|  | 	{ | |||
|  | 		this->stop(); | |||
|  | 	} | |||
|  | } | |||
|  | 
 | |||
|  | void ActionDelay::_reset() | |||
|  | { | |||
|  | 	Action::_reset(); | |||
|  | 	// <20><>¼<EFBFBD><C2BC>ǰʱ<C7B0><CAB1>
 | |||
|  | 	m_nLast = steady_clock::now(); | |||
|  | } |