| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | #include "..\easy2d.h"
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | ActionMoveBy::ActionMoveBy(float duration, CVector vec) : | 
					
						
							|  |  |  |  | 	Animation(duration) | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	m_MoveVector = vec; | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | ActionMoveBy::~ActionMoveBy() | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void ActionMoveBy::_init() | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	Animation::_init(); | 
					
						
							| 
									
										
										
										
											2017-10-06 02:32:33 +08:00
										 |  |  |  | 	m_BeginPos = m_pTargetSprite->getPos(); | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-08 12:30:45 +08:00
										 |  |  |  | void ActionMoveBy::_exec(LARGE_INTEGER nNow) | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-10-08 12:30:45 +08:00
										 |  |  |  | 	if (Animation::_isDelayEnough(nNow)) | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | 	{ | 
					
						
							|  |  |  |  | 		// <20><><EFBFBD><EFBFBD><EFBFBD>ƶ<EFBFBD>λ<EFBFBD><CEBB>
 | 
					
						
							|  |  |  |  | 		float scale = float(m_nDuration) / m_nTotalDuration; | 
					
						
							|  |  |  |  | 		// <20>ƶ<EFBFBD> Sprite
 | 
					
						
							| 
									
										
										
										
											2017-10-06 02:32:33 +08:00
										 |  |  |  | 		m_pTargetSprite->setPos(int(m_BeginPos.x + m_MoveVector.x * scale),  | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | 			int(m_BeginPos.y + m_MoveVector.y * scale)); | 
					
						
							|  |  |  |  | 		// <20>ж϶<D0B6><CFB6><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
 | 
					
						
							| 
									
										
										
										
											2017-09-30 16:18:45 +08:00
										 |  |  |  | 		if (_isEnd()) | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2017-10-08 12:30:45 +08:00
										 |  |  |  | 			this->stop(); | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | void ActionMoveBy::_reset() | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	Animation::_reset(); | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-30 16:18:45 +08:00
										 |  |  |  | ActionMoveBy * ActionMoveBy::copy() const | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-09-30 16:18:45 +08:00
										 |  |  |  | 	return new ActionMoveBy(m_nMilliSeconds / 1000.0f, m_MoveVector); | 
					
						
							| 
									
										
										
										
											2017-09-27 17:56:28 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | ActionMoveBy * ActionMoveBy::reverse() const | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 	return new ActionMoveBy(m_nTotalDuration / 1000.0f, CVector(-m_MoveVector.x, -m_MoveVector.y)); | 
					
						
							|  |  |  |  | } |