Action类重命名;去除Action构造器
This commit is contained in:
		
							parent
							
								
									f9181a2080
								
							
						
					
					
						commit
						83a90fcb0e
					
				|  | @ -1,133 +1,102 @@ | ||||||
| #include "..\e2daction.h" | #include "..\e2daction.h" | ||||||
|  | #include "..\e2dmanager.h" | ||||||
| 
 | 
 | ||||||
| e2d::ActionMoveBy * e2d::Action::MoveBy(double duration, Vector vector) | e2d::Action::Action()  | ||||||
|  | 	: _running(false) | ||||||
|  | 	, _done(false) | ||||||
|  | 	, _initialized(false) | ||||||
|  | 	, _target(nullptr) | ||||||
|  | 	, _fLast(0) | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionMoveBy(duration, vector); | 	ActionManager::__add(this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionMoveTo * e2d::Action::MoveTo(double duration, Point pos) | e2d::Action::~Action() | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionMoveTo(duration, pos); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionScaleBy * e2d::Action::ScaleBy(double duration, double scale) | bool e2d::Action::_isDone() | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionScaleBy(duration, scale); | 	return _done; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionScaleBy * e2d::Action::ScaleBy(double duration, double scaleX, double scaleY) | void e2d::Action::_startWithTarget(Node* target) | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionScaleBy(duration, scaleX, scaleY); | 	_target = target; | ||||||
|  | 	_running = true; | ||||||
|  | 	this->reset(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionScaleTo * e2d::Action::ScaleTo(double duration, double scale) | bool e2d::Action::isRunning() | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionScaleTo(duration, scale); | 	return _running; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionScaleTo * e2d::Action::ScaleTo(double duration, double scaleX, double scaleY) | void e2d::Action::resume() | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionScaleTo(duration, scaleX, scaleY); | 	_running = true; | ||||||
|  | 	_fLast = Time::getTotalTime(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionOpacityBy * e2d::Action::OpacityBy(double duration, double opacity) | void e2d::Action::pause() | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionOpacityBy(duration, opacity); | 	_running = false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionOpacityTo * e2d::Action::OpacityTo(double duration, double opacity) | void e2d::Action::stop() | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionOpacityTo(duration, opacity); | 	_done = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionFadeIn * e2d::Action::FadeIn(double duration) | e2d::String e2d::Action::getName() const | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionFadeIn(duration); | 	return _name; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionFadeOut * e2d::Action::FadeOut(double duration) | void e2d::Action::setName(const String& name) | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionFadeOut(duration); | 	_name = name; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionRotateBy * e2d::Action::RotateBy(double duration, double rotation) | e2d::Action * e2d::Action::reverse() const | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionRotateBy(duration, rotation); | 	WARN_IF(true, "Action cannot be reversed!"); | ||||||
|  | 	return nullptr; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionRotateTo * e2d::Action::RotateTo(double duration, double rotation) | e2d::Node * e2d::Action::getTarget() | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionRotateTo(duration, rotation); | 	return _target; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionTwo * e2d::Action::Two(ActionBase * pActionFirst, ActionBase * pActionSecond, bool bAtSameTime) | void e2d::Action::onDestroy() | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionTwo(pActionFirst, pActionSecond, bAtSameTime); | 	ActionManager::__remove(this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionDelay * e2d::Action::Delay(double duration) | void e2d::Action::_init() | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionDelay(duration); | 	_initialized = true; | ||||||
|  | 	// ¼Ç¼µ±Ç°Ê±¼ä
 | ||||||
|  | 	_fLast = Time::getTotalTime(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionLoop * e2d::Action::Loop(ActionBase * action, int times) | void e2d::Action::_update() | ||||||
| { | { | ||||||
| 	return new (std::nothrow) ActionLoop(action, times); | 	if (!_initialized) | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionFunc * e2d::Action::Func(const Function& func) |  | ||||||
| { |  | ||||||
| 	return new (std::nothrow) ActionFunc(func); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #ifdef HIGHER_THAN_VS2012 |  | ||||||
| 
 |  | ||||||
| e2d::ActionSequence * e2d::Action::Sequence(const std::initializer_list<ActionBase*>& vActions) |  | ||||||
| { |  | ||||||
| 	return new (std::nothrow) ActionSequence(vActions); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::Animation * e2d::Action::Animation(double interval, const std::initializer_list<Image*>& vFrames) |  | ||||||
| { |  | ||||||
| 	return new (std::nothrow) e2d::Animation(interval, vFrames); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #else |  | ||||||
| 
 |  | ||||||
| e2d::ActionSequence * e2d::Action::Sequence(int number, ActionBase * action1, ...) |  | ||||||
| { |  | ||||||
| 	auto action = new (std::nothrow) ActionSequence(); |  | ||||||
| 	if (action) |  | ||||||
| 	{ | 	{ | ||||||
| 		ActionBase ** ppAction = &action1; | 		_init(); | ||||||
| 
 |  | ||||||
| 		while (number > 0) |  | ||||||
| 		{ |  | ||||||
| 			WARN_IF((*ppAction) == nullptr, "ActionSequence NULL pointer exception!"); |  | ||||||
| 			action->add(*ppAction); |  | ||||||
| 			ppAction++; |  | ||||||
| 			number--; |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
| 	return action; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Animation * e2d::Action::Animation(double interval, int number, Image * frame, ...) | void e2d::Action::reset() | ||||||
| { | { | ||||||
| 	auto animation = new (std::nothrow) e2d::Animation(interval); | 	_initialized = false; | ||||||
| 	if (animation) | 	_done = false; | ||||||
| 	{ | 	_fLast = Time::getTotalTime(); | ||||||
| 		Image ** ppImage = &frame; |  | ||||||
| 
 |  | ||||||
| 		while (number > 0) |  | ||||||
| 		{ |  | ||||||
| 			WARN_IF((*ppImage) == nullptr, "Animation NULL pointer exception!"); |  | ||||||
| 			animation->add(*ppImage); |  | ||||||
| 			ppImage++; |  | ||||||
| 			number--; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	return animation; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #endif | void e2d::Action::_resetTime() | ||||||
|  | { | ||||||
|  | 	_fLast = Time::getTotalTime(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -1,103 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| #include "..\e2dmanager.h" |  | ||||||
| 
 |  | ||||||
| e2d::ActionBase::ActionBase()  |  | ||||||
| 	: _bRunning(false) |  | ||||||
| 	, _bEnding(false) |  | ||||||
| 	, _bInit(false) |  | ||||||
| 	, _pTarget(nullptr) |  | ||||||
| 	, _pParentScene(nullptr) |  | ||||||
| 	, _fLast(0) |  | ||||||
| { |  | ||||||
| 	ActionManager::__add(this); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionBase::~ActionBase() |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| bool e2d::ActionBase::_isDone() |  | ||||||
| { |  | ||||||
| 	return _bEnding; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionBase::_startWithTarget(Node* target) |  | ||||||
| { |  | ||||||
| 	_pTarget = target; |  | ||||||
| 	_bRunning = true; |  | ||||||
| 	this->reset(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| bool e2d::ActionBase::isRunning() |  | ||||||
| { |  | ||||||
| 	return _bRunning; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionBase::resume() |  | ||||||
| { |  | ||||||
| 	_bRunning = true; |  | ||||||
| 	_fLast = Time::getTotalTime(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionBase::pause() |  | ||||||
| { |  | ||||||
| 	_bRunning = false; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionBase::stop() |  | ||||||
| { |  | ||||||
| 	_bEnding = true; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::String e2d::ActionBase::getName() const |  | ||||||
| { |  | ||||||
| 	return _sName; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionBase::setName(const String& name) |  | ||||||
| { |  | ||||||
| 	_sName = name; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionBase * e2d::ActionBase::reverse() const |  | ||||||
| { |  | ||||||
| 	WARN_IF(true, "ActionBase cannot be reversed!"); |  | ||||||
| 	return nullptr; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::Node * e2d::ActionBase::getTarget() |  | ||||||
| { |  | ||||||
| 	return _pTarget; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionBase::destroy() |  | ||||||
| { |  | ||||||
| 	ActionManager::__remove(this); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionBase::_init() |  | ||||||
| { |  | ||||||
| 	_bInit = true; |  | ||||||
| 	// ¼Ç¼µ±Ç°Ê±¼ä
 |  | ||||||
| 	_fLast = Time::getTotalTime(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionBase::_update() |  | ||||||
| { |  | ||||||
| 	if (!_bInit) |  | ||||||
| 	{ |  | ||||||
| 		_init(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionBase::reset() |  | ||||||
| { |  | ||||||
| 	_bInit = false; |  | ||||||
| 	_bEnding = false; |  | ||||||
| 	_fLast = Time::getTotalTime(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionBase::_resetTime() |  | ||||||
| { |  | ||||||
| 	_fLast = Time::getTotalTime(); |  | ||||||
| } |  | ||||||
|  | @ -1,26 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| 
 |  | ||||||
| e2d::ActionDelay::ActionDelay(double duration) |  | ||||||
| { |  | ||||||
| 	_fDelayTime = max(duration, 0); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionDelay * e2d::ActionDelay::clone() const |  | ||||||
| { |  | ||||||
| 	return new ActionDelay(_fDelayTime); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionDelay::_init() |  | ||||||
| { |  | ||||||
| 	ActionBase::_init(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionDelay::_update() |  | ||||||
| { |  | ||||||
| 	ActionBase::_update(); |  | ||||||
| 	// 判断时间间隔是否足够
 |  | ||||||
| 	if ((Time::getTotalTime() - _fLast) >= _fDelayTime) |  | ||||||
| 	{ |  | ||||||
| 		this->stop(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  | @ -1,22 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| 
 |  | ||||||
| e2d::ActionFunc::ActionFunc(const Function& func) : |  | ||||||
| 	_Callback(func) |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionFunc * e2d::ActionFunc::clone() const |  | ||||||
| { |  | ||||||
| 	return new ActionFunc(_Callback); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionFunc::_init() |  | ||||||
| { |  | ||||||
| 	// 执行函数对象的动作不需要初始化
 |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionFunc::_update() |  | ||||||
| { |  | ||||||
| 	_Callback(); |  | ||||||
| 	this->stop(); |  | ||||||
| } |  | ||||||
|  | @ -1,30 +1,30 @@ | ||||||
| #include "..\e2daction.h" | #include "..\e2daction.h" | ||||||
| 
 | 
 | ||||||
| e2d::ActionGradual::ActionGradual(double duration) | e2d::ActionGradual::ActionGradual(double duration) | ||||||
| 	: _fRateOfProgress(0) | 	: _delta(0) | ||||||
| { | { | ||||||
| 	_fDuration = max(duration, 0); | 	_duration = max(duration, 0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::ActionGradual::_init() | void e2d::ActionGradual::_init() | ||||||
| { | { | ||||||
| 	ActionBase::_init(); | 	Action::_init(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::ActionGradual::_update() | void e2d::ActionGradual::_update() | ||||||
| { | { | ||||||
| 	ActionBase::_update(); | 	Action::_update(); | ||||||
| 	// 判断时间间隔是否足够
 | 	// 判断时间间隔是否足够
 | ||||||
| 	if (_fDuration == 0) | 	if (_duration == 0) | ||||||
| 	{ | 	{ | ||||||
| 		_fRateOfProgress = 1; | 		_delta = 1; | ||||||
| 		this->stop(); | 		this->stop(); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	// 计算动画进度
 | 	// 计算动画进度
 | ||||||
| 	_fRateOfProgress = min((Time::getTotalTime() - _fLast) / _fDuration, 1); | 	_delta = min((Time::getTotalTime() - _fLast) / _duration, 1); | ||||||
| 	// 判断动作是否结束
 | 	// 判断动作是否结束
 | ||||||
| 	if (_fRateOfProgress >= 1) | 	if (_delta >= 1) | ||||||
| 	{ | 	{ | ||||||
| 		this->stop(); | 		this->stop(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -1,67 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| #include "..\e2dmanager.h" |  | ||||||
| 
 |  | ||||||
| e2d::ActionLoop::ActionLoop(ActionBase * action, int times /* = -1 */) |  | ||||||
| 	: _pAction(action) |  | ||||||
| 	, _nTimes(0) |  | ||||||
| 	, _nTotalTimes(times) |  | ||||||
| { |  | ||||||
| 	ASSERT(_pAction, "ActionLoop NULL pointer exception!"); |  | ||||||
| 	_pAction->retain(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionLoop::~ActionLoop() |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionLoop * e2d::ActionLoop::clone() const |  | ||||||
| { |  | ||||||
| 	return new ActionLoop(_pAction->clone()); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionLoop::_init() |  | ||||||
| { |  | ||||||
| 	ActionBase::_init(); |  | ||||||
| 	_pAction->_pTarget = _pTarget; |  | ||||||
| 	_pAction->_init(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionLoop::_update() |  | ||||||
| { |  | ||||||
| 	ActionBase::_update(); |  | ||||||
| 
 |  | ||||||
| 	if (_nTimes == _nTotalTimes) |  | ||||||
| 	{ |  | ||||||
| 		this->stop(); |  | ||||||
| 		return; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	_pAction->_update(); |  | ||||||
| 
 |  | ||||||
| 	if (_pAction->_isDone()) |  | ||||||
| 	{ |  | ||||||
| 		_nTimes++; |  | ||||||
| 		 |  | ||||||
| 		ActionBase::reset(); |  | ||||||
| 		_pAction->reset(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionLoop::reset() |  | ||||||
| { |  | ||||||
| 	ActionBase::reset(); |  | ||||||
| 
 |  | ||||||
| 	_pAction->reset(); |  | ||||||
| 	_nTimes = 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionLoop::destroy() |  | ||||||
| { |  | ||||||
| 	ActionBase::destroy(); |  | ||||||
| 	SafeRelease(&_pAction); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionLoop::_resetTime() |  | ||||||
| { |  | ||||||
| 	_pAction->_resetTime(); |  | ||||||
| } |  | ||||||
|  | @ -1,41 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| e2d::ActionMoveBy::ActionMoveBy(double duration, Vector vector) : |  | ||||||
| 	ActionGradual(duration) |  | ||||||
| { |  | ||||||
| 	_MoveVec = vector; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionMoveBy::_init() |  | ||||||
| { |  | ||||||
| 	ActionGradual::_init(); |  | ||||||
| 	if (_pTarget) |  | ||||||
| 	{ |  | ||||||
| 		_BeginPos = _pTarget->getPos(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionMoveBy::_update() |  | ||||||
| { |  | ||||||
| 	ActionGradual::_update(); |  | ||||||
| 
 |  | ||||||
| 	if (_pTarget == nullptr) |  | ||||||
| 	{ |  | ||||||
| 		this->stop(); |  | ||||||
| 		return; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	// ÒÆ¶¯½Úµã
 |  | ||||||
| 	_pTarget->setPos(_BeginPos + _MoveVec * _fRateOfProgress); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionMoveBy * e2d::ActionMoveBy::clone() const |  | ||||||
| { |  | ||||||
| 	return new ActionMoveBy(_fDuration, _MoveVec); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionMoveBy * e2d::ActionMoveBy::reverse() const |  | ||||||
| { |  | ||||||
| 	return new ActionMoveBy(_fDuration, -_MoveVec); |  | ||||||
| } |  | ||||||
|  | @ -1,18 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| 
 |  | ||||||
| e2d::ActionMoveTo::ActionMoveTo(double duration, Point pos) : |  | ||||||
| 	ActionMoveBy(duration, Vector()) |  | ||||||
| { |  | ||||||
| 	_EndPos = pos; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionMoveTo * e2d::ActionMoveTo::clone() const |  | ||||||
| { |  | ||||||
| 	return new ActionMoveTo(_fDuration, _EndPos); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionMoveTo::_init() |  | ||||||
| { |  | ||||||
| 	ActionMoveBy::_init(); |  | ||||||
| 	_MoveVec = _EndPos - _BeginPos; |  | ||||||
| } |  | ||||||
|  | @ -1,40 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| e2d::ActionOpacityBy::ActionOpacityBy(double duration, double opacity) : |  | ||||||
| 	ActionGradual(duration) |  | ||||||
| { |  | ||||||
| 	_nVariation = opacity; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionOpacityBy::_init() |  | ||||||
| { |  | ||||||
| 	ActionGradual::_init(); |  | ||||||
| 	if (_pTarget) |  | ||||||
| 	{ |  | ||||||
| 		_nBeginVal = _pTarget->getOpacity(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionOpacityBy::_update() |  | ||||||
| { |  | ||||||
| 	ActionGradual::_update(); |  | ||||||
| 
 |  | ||||||
| 	if (_pTarget == nullptr) |  | ||||||
| 	{ |  | ||||||
| 		this->stop(); |  | ||||||
| 		return; |  | ||||||
| 	} |  | ||||||
| 	// ÉèÖýڵã͸Ã÷¶È
 |  | ||||||
| 	_pTarget->setOpacity(_nBeginVal + _nVariation * _fRateOfProgress); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionOpacityBy * e2d::ActionOpacityBy::clone() const |  | ||||||
| { |  | ||||||
| 	return new ActionOpacityBy(_fDuration, _nVariation); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionOpacityBy * e2d::ActionOpacityBy::reverse() const |  | ||||||
| { |  | ||||||
| 	return new ActionOpacityBy(_fDuration, -_nVariation); |  | ||||||
| } |  | ||||||
|  | @ -1,19 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| e2d::ActionOpacityTo::ActionOpacityTo(double duration, double opacity) : |  | ||||||
| 	ActionOpacityBy(duration, 0) |  | ||||||
| { |  | ||||||
| 	_nEndVal = opacity; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionOpacityTo * e2d::ActionOpacityTo::clone() const |  | ||||||
| { |  | ||||||
| 	return new ActionOpacityTo(_fDuration, _nEndVal); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionOpacityTo::_init() |  | ||||||
| { |  | ||||||
| 	ActionOpacityBy::_init(); |  | ||||||
| 	_nVariation = _nEndVal - _nBeginVal; |  | ||||||
| } |  | ||||||
|  | @ -1,41 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| e2d::ActionRotateBy::ActionRotateBy(double duration, double rotation) : |  | ||||||
| 	ActionGradual(duration) |  | ||||||
| { |  | ||||||
| 	_nVariation = rotation; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionRotateBy::_init() |  | ||||||
| { |  | ||||||
| 	ActionGradual::_init(); |  | ||||||
| 	if (_pTarget) |  | ||||||
| 	{ |  | ||||||
| 		_nBeginVal = _pTarget->getRotation(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionRotateBy::_update() |  | ||||||
| { |  | ||||||
| 	ActionGradual::_update(); |  | ||||||
| 
 |  | ||||||
| 	if (_pTarget == nullptr) |  | ||||||
| 	{ |  | ||||||
| 		this->stop(); |  | ||||||
| 		return; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	// Ðýת½Úµã
 |  | ||||||
| 	_pTarget->setRotation(_nBeginVal + _nVariation * _fRateOfProgress); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionRotateBy * e2d::ActionRotateBy::clone() const |  | ||||||
| { |  | ||||||
| 	return new ActionRotateBy(_fDuration, _nVariation); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionRotateBy * e2d::ActionRotateBy::reverse() const |  | ||||||
| { |  | ||||||
| 	return new ActionRotateBy(_fDuration, -_nVariation); |  | ||||||
| } |  | ||||||
|  | @ -1,19 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| e2d::ActionRotateTo::ActionRotateTo(double duration, double rotation) : |  | ||||||
| 	ActionRotateBy(duration, 0) |  | ||||||
| { |  | ||||||
| 	_nEndVal = rotation; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionRotateTo * e2d::ActionRotateTo::clone() const |  | ||||||
| { |  | ||||||
| 	return new ActionRotateTo(_fDuration, _nEndVal); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionRotateTo::_init() |  | ||||||
| { |  | ||||||
| 	ActionRotateBy::_init(); |  | ||||||
| 	_nVariation = _nEndVal - _nBeginVal; |  | ||||||
| } |  | ||||||
|  | @ -1,52 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| e2d::ActionScaleBy::ActionScaleBy(double duration, double scale) |  | ||||||
| 	: ActionGradual(duration) |  | ||||||
| { |  | ||||||
| 	_nVariationX = scale; |  | ||||||
| 	_nVariationY = scale; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionScaleBy::ActionScaleBy(double duration, double scaleX, double scaleY) |  | ||||||
| 	: ActionGradual(duration) |  | ||||||
| { |  | ||||||
| 	_nVariationX = scaleX; |  | ||||||
| 	_nVariationY = scaleY; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionScaleBy::_init() |  | ||||||
| { |  | ||||||
| 	ActionGradual::_init(); |  | ||||||
| 	if (_pTarget) |  | ||||||
| 	{ |  | ||||||
| 		_nBeginScaleX = _pTarget->getScaleX(); |  | ||||||
| 		_nBeginScaleY = _pTarget->getScaleY(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionScaleBy::_update() |  | ||||||
| { |  | ||||||
| 	ActionGradual::_update(); |  | ||||||
| 
 |  | ||||||
| 	if (_pTarget == nullptr) |  | ||||||
| 	{ |  | ||||||
| 		this->stop(); |  | ||||||
| 		return; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	// Ëõ·Å½Úµã
 |  | ||||||
| 	_pTarget->setScale( |  | ||||||
| 		_nBeginScaleX + _nVariationX * _fRateOfProgress,  |  | ||||||
| 		_nBeginScaleY + _nVariationY * _fRateOfProgress); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionScaleBy * e2d::ActionScaleBy::clone() const |  | ||||||
| { |  | ||||||
| 	return new ActionScaleBy(_fDuration, _nVariationX, _nVariationY); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionScaleBy * e2d::ActionScaleBy::reverse() const |  | ||||||
| { |  | ||||||
| 	return new ActionScaleBy(_fDuration, -_nVariationX, -_nVariationY); |  | ||||||
| } |  | ||||||
|  | @ -1,27 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| 
 |  | ||||||
| e2d::ActionScaleTo::ActionScaleTo(double duration, double scale) |  | ||||||
| 	: ActionScaleBy(duration, 0, 0) |  | ||||||
| { |  | ||||||
| 	_nEndScaleX = scale; |  | ||||||
| 	_nEndScaleY = scale; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionScaleTo::ActionScaleTo(double duration, double scaleX, double scaleY) |  | ||||||
| 	: ActionScaleBy(duration, 0, 0) |  | ||||||
| { |  | ||||||
| 	_nEndScaleX = scaleX; |  | ||||||
| 	_nEndScaleY = scaleY; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionScaleTo * e2d::ActionScaleTo::clone() const |  | ||||||
| { |  | ||||||
| 	return new ActionScaleTo(_fDuration, _nEndScaleX, _nEndScaleY); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionScaleTo::_init() |  | ||||||
| { |  | ||||||
| 	ActionScaleBy::_init(); |  | ||||||
| 	_nVariationX = _nEndScaleX - _nBeginScaleX; |  | ||||||
| 	_nVariationY = _nEndScaleY - _nBeginScaleY; |  | ||||||
| } |  | ||||||
|  | @ -1,156 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| 
 |  | ||||||
| e2d::ActionSequence::ActionSequence() |  | ||||||
| 	: _nActionIndex(0) |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #ifdef HIGHER_THAN_VS2012 |  | ||||||
| e2d::ActionSequence::ActionSequence(const std::initializer_list<ActionBase*>& vActions) |  | ||||||
| 	: _nActionIndex(0) |  | ||||||
| { |  | ||||||
| 	this->add(vActions); |  | ||||||
| } |  | ||||||
| #else |  | ||||||
| e2d::ActionSequence::ActionSequence(int number, ActionBase * action1, ...) : |  | ||||||
| 	_nActionIndex(0) |  | ||||||
| { |  | ||||||
| 	ActionBase ** ppAction = &action1; |  | ||||||
| 
 |  | ||||||
| 	while (number > 0) |  | ||||||
| 	{ |  | ||||||
| 		WARN_IF((*ppAction) == nullptr, "ActionSequence NULL pointer exception!"); |  | ||||||
| 		this->add(*ppAction); |  | ||||||
| 		ppAction++; |  | ||||||
| 		number--; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| e2d::ActionSequence::~ActionSequence() |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionSequence::_init() |  | ||||||
| { |  | ||||||
| 	ActionBase::_init(); |  | ||||||
| 	// 将所有动作与目标绑定
 |  | ||||||
| 	if (_pTarget) |  | ||||||
| 	{ |  | ||||||
| 		for (auto action : _vActions) |  | ||||||
| 		{ |  | ||||||
| 			action->_pTarget = _pTarget; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	// 初始化第一个动作
 |  | ||||||
| 	_vActions[0]->_init(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionSequence::destroy() |  | ||||||
| { |  | ||||||
| 	ActionBase::destroy(); |  | ||||||
| 	for (auto action : _vActions) |  | ||||||
| 	{ |  | ||||||
| 		SafeRelease(&action); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionSequence::_update() |  | ||||||
| { |  | ||||||
| 	ActionBase::_update(); |  | ||||||
| 
 |  | ||||||
| 	auto &action = _vActions[_nActionIndex]; |  | ||||||
| 	action->_update(); |  | ||||||
| 
 |  | ||||||
| 	if (action->_isDone()) |  | ||||||
| 	{ |  | ||||||
| 		_nActionIndex++; |  | ||||||
| 		if (_nActionIndex == _vActions.size()) |  | ||||||
| 		{ |  | ||||||
| 			this->stop(); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			_vActions[_nActionIndex]->_init(); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionSequence::reset() |  | ||||||
| { |  | ||||||
| 	ActionBase::reset(); |  | ||||||
| 	for (auto action : _vActions) |  | ||||||
| 	{ |  | ||||||
| 		action->reset(); |  | ||||||
| 	} |  | ||||||
| 	_nActionIndex = 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionSequence::_resetTime() |  | ||||||
| { |  | ||||||
| 	for (auto action : _vActions) |  | ||||||
| 	{ |  | ||||||
| 		action->_resetTime(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionSequence::add(ActionBase * action) |  | ||||||
| { |  | ||||||
| 	if (action) |  | ||||||
| 	{ |  | ||||||
| 		_vActions.push_back(action); |  | ||||||
| 		action->retain(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #ifdef HIGHER_THAN_VS2012 |  | ||||||
| void e2d::ActionSequence::add(const std::initializer_list<ActionBase*>& vActions) |  | ||||||
| { |  | ||||||
| 	for (const auto &action : vActions) |  | ||||||
| 	{ |  | ||||||
| 		this->add(action); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| #else |  | ||||||
| void e2d::ActionSequence::add(int number, ActionBase * action, ...) |  | ||||||
| { |  | ||||||
| 	ActionBase ** ppAction = &action; |  | ||||||
| 
 |  | ||||||
| 	while (number > 0) |  | ||||||
| 	{ |  | ||||||
| 		WARN_IF((*ppAction) == nullptr, "ActionSequence NULL pointer exception!"); |  | ||||||
| 		this->add(*ppAction); |  | ||||||
| 		ppAction++; |  | ||||||
| 		number--; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| e2d::ActionSequence * e2d::ActionSequence::clone() const |  | ||||||
| { |  | ||||||
| 	auto a = new ActionSequence(); |  | ||||||
| 	for (auto action : _vActions) |  | ||||||
| 	{ |  | ||||||
| 		a->add(action->clone()); |  | ||||||
| 	} |  | ||||||
| 	return a; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionSequence * e2d::ActionSequence::reverse(bool actionReverse) const |  | ||||||
| { |  | ||||||
| 	auto a = new ActionSequence(); |  | ||||||
| 	for (auto action : _vActions) |  | ||||||
| 	{ |  | ||||||
| 		if (actionReverse) |  | ||||||
| 		{ |  | ||||||
| 			a->add(action->reverse()); |  | ||||||
| 		} |  | ||||||
| 		else |  | ||||||
| 		{ |  | ||||||
| 			a->add(action->clone()); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	// 将动作顺序逆序排列
 |  | ||||||
| 	a->_vActions.reserve(_vActions.size()); |  | ||||||
| 	return a; |  | ||||||
| } |  | ||||||
|  | @ -1,95 +0,0 @@ | ||||||
| #include "..\e2daction.h" |  | ||||||
| 
 |  | ||||||
| e2d::ActionTwo::ActionTwo(ActionBase * pActionFirst, ActionBase * pActionSecond, bool bAtSameTime/* = false*/) |  | ||||||
| 	: _pFirstAction(pActionFirst) |  | ||||||
| 	, _pSecondAction(pActionSecond) |  | ||||||
| 	, _bAtSameTime(bAtSameTime) |  | ||||||
| { |  | ||||||
| 	ASSERT(_pFirstAction && _pSecondAction, "ActionTwo NULL pointer exception!"); |  | ||||||
| 	_pFirstAction->retain(); |  | ||||||
| 	_pSecondAction->retain(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionTwo::~ActionTwo() |  | ||||||
| { |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionTwo * e2d::ActionTwo::clone() const |  | ||||||
| { |  | ||||||
| 	return new ActionTwo(_pFirstAction->clone(), _pSecondAction->clone()); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| e2d::ActionTwo * e2d::ActionTwo::reverse(bool actionReverse) const |  | ||||||
| { |  | ||||||
| 	if (actionReverse) |  | ||||||
| 	{ |  | ||||||
| 		return new ActionTwo(_pSecondAction->reverse(), _pFirstAction->reverse()); |  | ||||||
| 	} |  | ||||||
| 	else |  | ||||||
| 	{ |  | ||||||
| 		return new ActionTwo(_pSecondAction->clone(), _pFirstAction->clone()); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionTwo::_init() |  | ||||||
| { |  | ||||||
| 	ActionBase::_init(); |  | ||||||
| 	_pFirstAction->_pTarget = _pTarget; |  | ||||||
| 	_pSecondAction->_pTarget = _pTarget; |  | ||||||
| 
 |  | ||||||
| 	_pFirstAction->_init(); |  | ||||||
| 	if (_bAtSameTime) _pSecondAction->_init(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionTwo::_update() |  | ||||||
| { |  | ||||||
| 	ActionBase::_update(); |  | ||||||
| 
 |  | ||||||
| 	if (!_pFirstAction->_isDone()) |  | ||||||
| 	{ |  | ||||||
| 		_pFirstAction->_update(); |  | ||||||
| 
 |  | ||||||
| 		if (!_bAtSameTime && _pFirstAction->_isDone()) |  | ||||||
| 		{ |  | ||||||
| 			_pSecondAction->_init(); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if (_bAtSameTime) |  | ||||||
| 	{ |  | ||||||
| 		if (!_pSecondAction->_isDone()) |  | ||||||
| 		{ |  | ||||||
| 			_pSecondAction->_update(); |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	else if (_pFirstAction->_isDone()) |  | ||||||
| 	{ |  | ||||||
| 		_pSecondAction->_update(); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if (_pFirstAction->_isDone() && _pSecondAction->_isDone()) |  | ||||||
| 	{ |  | ||||||
| 		this->stop(); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionTwo::reset() |  | ||||||
| { |  | ||||||
| 	ActionBase::reset(); |  | ||||||
| 
 |  | ||||||
| 	_pFirstAction->reset(); |  | ||||||
| 	_pSecondAction->reset(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionTwo::destroy() |  | ||||||
| { |  | ||||||
| 	ActionBase::destroy(); |  | ||||||
| 	SafeRelease(&_pFirstAction); |  | ||||||
| 	SafeRelease(&_pSecondAction); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void e2d::ActionTwo::_resetTime() |  | ||||||
| { |  | ||||||
| 	_pFirstAction->_resetTime(); |  | ||||||
| 	_pSecondAction->_resetTime(); |  | ||||||
| } |  | ||||||
|  | @ -1,29 +1,29 @@ | ||||||
| #include "..\e2daction.h" | #include "..\e2daction.h" | ||||||
| 
 | 
 | ||||||
| e2d::Animation::Animation()  | e2d::Animation::Animation()  | ||||||
| 	: _nFrameIndex(0) | 	: _frameIndex(0) | ||||||
| 	, _fInterval(1) | 	, _interval(1) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Animation::Animation(double interval) | e2d::Animation::Animation(double interval) | ||||||
| 	: _nFrameIndex(0) | 	: _frameIndex(0) | ||||||
| 	, _fInterval(interval) | 	, _interval(interval) | ||||||
| { | { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #ifdef HIGHER_THAN_VS2012 | #ifdef HIGHER_THAN_VS2012 | ||||||
| 
 | 
 | ||||||
| e2d::Animation::Animation(const std::initializer_list<Image*>& vImages) | e2d::Animation::Animation(const std::initializer_list<Image*>& vImages) | ||||||
| 	: _nFrameIndex(0) | 	: _frameIndex(0) | ||||||
| 	, _fInterval(1) | 	, _interval(1) | ||||||
| { | { | ||||||
| 	this->add(vImages); | 	this->add(vImages); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Animation::Animation(double interval, const std::initializer_list<Image*>& vImages) | e2d::Animation::Animation(double interval, const std::initializer_list<Image*>& vImages) | ||||||
| 	: _nFrameIndex(0) | 	: _frameIndex(0) | ||||||
| 	, _fInterval(interval) | 	, _interval(interval) | ||||||
| { | { | ||||||
| 	this->add(vImages); | 	this->add(vImages); | ||||||
| } | } | ||||||
|  | @ -31,8 +31,8 @@ e2d::Animation::Animation(double interval, const std::initializer_list<Image*>& | ||||||
| #else | #else | ||||||
| 
 | 
 | ||||||
| e2d::Animation::Animation(int number, Image * frame, ...) | e2d::Animation::Animation(int number, Image * frame, ...) | ||||||
| 	: _nFrameIndex(0) | 	: _frameIndex(0) | ||||||
| 	, _fInterval(1) | 	, _interval(1) | ||||||
| { | { | ||||||
| 	Image ** ppImage = &frame; | 	Image ** ppImage = &frame; | ||||||
| 
 | 
 | ||||||
|  | @ -46,8 +46,8 @@ e2d::Animation::Animation(int number, Image * frame, ...) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Animation::Animation(double interval, int number, Image * frame, ...) | e2d::Animation::Animation(double interval, int number, Image * frame, ...) | ||||||
| 	: _nFrameIndex(0) | 	: _frameIndex(0) | ||||||
| 	, _fInterval(interval) | 	, _interval(interval) | ||||||
| { | { | ||||||
| 	Image ** ppImage = &frame; | 	Image ** ppImage = &frame; | ||||||
| 
 | 
 | ||||||
|  | @ -68,34 +68,34 @@ e2d::Animation::~Animation() | ||||||
| 
 | 
 | ||||||
| void e2d::Animation::setInterval(double interval) | void e2d::Animation::setInterval(double interval) | ||||||
| { | { | ||||||
| 	_fInterval = max(interval, 0); | 	_interval = max(interval, 0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Animation::_init() | void e2d::Animation::_init() | ||||||
| { | { | ||||||
| 	ActionBase::_init(); | 	Action::_init(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Animation::_update() | void e2d::Animation::_update() | ||||||
| { | { | ||||||
| 	ActionBase::_update(); | 	Action::_update(); | ||||||
| 
 | 
 | ||||||
| 	if (_pTarget == nullptr) | 	if (_target == nullptr) | ||||||
| 	{ | 	{ | ||||||
| 		this->stop(); | 		this->stop(); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// 判断时间间隔是否足够
 | 	// 判断时间间隔是否足够
 | ||||||
| 	while ((Time::getTotalTime() - _fLast) >= _fInterval) | 	while ((Time::getTotalTime() - _fLast) >= _interval) | ||||||
| 	{ | 	{ | ||||||
| 		// 重新记录时间
 | 		// 重新记录时间
 | ||||||
| 		_fLast += _fInterval; | 		_fLast += _interval; | ||||||
| 		// 加载关键帧
 | 		// 加载关键帧
 | ||||||
| 		static_cast<Sprite*>(_pTarget)->open(_vFrames[_nFrameIndex]); | 		static_cast<Sprite*>(_target)->open(_frames[_frameIndex]); | ||||||
| 		_nFrameIndex++; | 		_frameIndex++; | ||||||
| 		// 判断动作是否结束
 | 		// 判断动作是否结束
 | ||||||
| 		if (_nFrameIndex == _vFrames.size()) | 		if (_frameIndex == _frames.size()) | ||||||
| 		{ | 		{ | ||||||
| 			this->stop(); | 			this->stop(); | ||||||
| 			break; | 			break; | ||||||
|  | @ -105,14 +105,14 @@ void e2d::Animation::_update() | ||||||
| 
 | 
 | ||||||
| void e2d::Animation::reset() | void e2d::Animation::reset() | ||||||
| { | { | ||||||
| 	ActionBase::reset(); | 	Action::reset(); | ||||||
| 	_nFrameIndex = 0; | 	_frameIndex = 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Animation::destroy() | void e2d::Animation::onDestroy() | ||||||
| { | { | ||||||
| 	ActionBase::destroy(); | 	Action::onDestroy(); | ||||||
| 	for (auto frame : _vFrames) | 	for (auto frame : _frames) | ||||||
| 	{ | 	{ | ||||||
| 		SafeRelease(&frame); | 		SafeRelease(&frame); | ||||||
| 	} | 	} | ||||||
|  | @ -122,7 +122,7 @@ void e2d::Animation::add(Image * frame) | ||||||
| { | { | ||||||
| 	if (frame) | 	if (frame) | ||||||
| 	{ | 	{ | ||||||
| 		_vFrames.push_back(frame); | 		_frames.push_back(frame); | ||||||
| 		frame->retain(); | 		frame->retain(); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | @ -152,8 +152,8 @@ void e2d::Animation::add(int number, Image * frame, ...) | ||||||
| 
 | 
 | ||||||
| e2d::Animation * e2d::Animation::clone() const | e2d::Animation * e2d::Animation::clone() const | ||||||
| { | { | ||||||
| 	auto a = new Animation(_fInterval); | 	auto a = new Animation(_interval); | ||||||
| 	for (auto frame : _vFrames) | 	for (auto frame : _frames) | ||||||
| 	{ | 	{ | ||||||
| 		a->add(frame); | 		a->add(frame); | ||||||
| 	} | 	} | ||||||
|  | @ -163,6 +163,6 @@ e2d::Animation * e2d::Animation::clone() const | ||||||
| e2d::Animation * e2d::Animation::reverse() const | e2d::Animation * e2d::Animation::reverse() const | ||||||
| { | { | ||||||
| 	auto a = this->clone(); | 	auto a = this->clone(); | ||||||
| 	a->_vFrames.reserve(_vFrames.size()); | 	a->_frames.reserve(_frames.size()); | ||||||
| 	return a; | 	return a; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -0,0 +1,21 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | 
 | ||||||
|  | e2d::CallFunc::CallFunc(const Function& func) : | ||||||
|  | 	_func(func) | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::CallFunc * e2d::CallFunc::clone() const | ||||||
|  | { | ||||||
|  | 	return new CallFunc(_func); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::CallFunc::_init() | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::CallFunc::_update() | ||||||
|  | { | ||||||
|  | 	_func(); | ||||||
|  | 	this->stop(); | ||||||
|  | } | ||||||
|  | @ -0,0 +1,26 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | 
 | ||||||
|  | e2d::Delay::Delay(double duration) | ||||||
|  | { | ||||||
|  | 	_delay = max(duration, 0); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::Delay * e2d::Delay::clone() const | ||||||
|  | { | ||||||
|  | 	return new Delay(_delay); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Delay::_init() | ||||||
|  | { | ||||||
|  | 	Action::_init(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Delay::_update() | ||||||
|  | { | ||||||
|  | 	Action::_update(); | ||||||
|  | 	// 判断时间间隔是否足够
 | ||||||
|  | 	if ((Time::getTotalTime() - _fLast) >= _delay) | ||||||
|  | 	{ | ||||||
|  | 		this->stop(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | @ -0,0 +1,67 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | #include "..\e2dmanager.h" | ||||||
|  | 
 | ||||||
|  | e2d::Loop::Loop(Action * action, int times /* = -1 */) | ||||||
|  | 	: _action(action) | ||||||
|  | 	, _times(0) | ||||||
|  | 	, _totalTimes(times) | ||||||
|  | { | ||||||
|  | 	ASSERT(_action, "Loop NULL pointer exception!"); | ||||||
|  | 	_action->retain(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::Loop::~Loop() | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::Loop * e2d::Loop::clone() const | ||||||
|  | { | ||||||
|  | 	return new Loop(_action->clone()); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Loop::_init() | ||||||
|  | { | ||||||
|  | 	Action::_init(); | ||||||
|  | 	_action->_target = _target; | ||||||
|  | 	_action->_init(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Loop::_update() | ||||||
|  | { | ||||||
|  | 	Action::_update(); | ||||||
|  | 
 | ||||||
|  | 	if (_times == _totalTimes) | ||||||
|  | 	{ | ||||||
|  | 		this->stop(); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	_action->_update(); | ||||||
|  | 
 | ||||||
|  | 	if (_action->_isDone()) | ||||||
|  | 	{ | ||||||
|  | 		_times++; | ||||||
|  | 		 | ||||||
|  | 		Action::reset(); | ||||||
|  | 		_action->reset(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Loop::reset() | ||||||
|  | { | ||||||
|  | 	Action::reset(); | ||||||
|  | 
 | ||||||
|  | 	_action->reset(); | ||||||
|  | 	_times = 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Loop::onDestroy() | ||||||
|  | { | ||||||
|  | 	Action::onDestroy(); | ||||||
|  | 	SafeRelease(&_action); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Loop::_resetTime() | ||||||
|  | { | ||||||
|  | 	_action->_resetTime(); | ||||||
|  | } | ||||||
|  | @ -0,0 +1,40 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | e2d::MoveBy::MoveBy(double duration, Vector vector) : | ||||||
|  | 	ActionGradual(duration) | ||||||
|  | { | ||||||
|  | 	_deltaPos = vector; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::MoveBy::_init() | ||||||
|  | { | ||||||
|  | 	ActionGradual::_init(); | ||||||
|  | 	if (_target) | ||||||
|  | 	{ | ||||||
|  | 		_startPos = _target->getPos(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::MoveBy::_update() | ||||||
|  | { | ||||||
|  | 	ActionGradual::_update(); | ||||||
|  | 
 | ||||||
|  | 	if (_target == nullptr) | ||||||
|  | 	{ | ||||||
|  | 		this->stop(); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	_target->setPos(_startPos + _deltaPos * _delta); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::MoveBy * e2d::MoveBy::clone() const | ||||||
|  | { | ||||||
|  | 	return new MoveBy(_duration, _deltaPos); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::MoveBy * e2d::MoveBy::reverse() const | ||||||
|  | { | ||||||
|  | 	return new MoveBy(_duration, -_deltaPos); | ||||||
|  | } | ||||||
|  | @ -0,0 +1,18 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | 
 | ||||||
|  | e2d::MoveTo::MoveTo(double duration, Point pos) : | ||||||
|  | 	MoveBy(duration, Vector()) | ||||||
|  | { | ||||||
|  | 	_endPos = pos; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::MoveTo * e2d::MoveTo::clone() const | ||||||
|  | { | ||||||
|  | 	return new MoveTo(_duration, _endPos); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::MoveTo::_init() | ||||||
|  | { | ||||||
|  | 	MoveBy::_init(); | ||||||
|  | 	_deltaPos = _endPos - _startPos; | ||||||
|  | } | ||||||
|  | @ -0,0 +1,40 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | e2d::OpacityBy::OpacityBy(double duration, double opacity) : | ||||||
|  | 	ActionGradual(duration) | ||||||
|  | { | ||||||
|  | 	_deltaVal = opacity; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::OpacityBy::_init() | ||||||
|  | { | ||||||
|  | 	ActionGradual::_init(); | ||||||
|  | 	if (_target) | ||||||
|  | 	{ | ||||||
|  | 		_startVal = _target->getOpacity(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::OpacityBy::_update() | ||||||
|  | { | ||||||
|  | 	ActionGradual::_update(); | ||||||
|  | 
 | ||||||
|  | 	if (_target == nullptr) | ||||||
|  | 	{ | ||||||
|  | 		this->stop(); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	_target->setOpacity(_startVal + _deltaVal * _delta); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::OpacityBy * e2d::OpacityBy::clone() const | ||||||
|  | { | ||||||
|  | 	return new OpacityBy(_duration, _deltaVal); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::OpacityBy * e2d::OpacityBy::reverse() const | ||||||
|  | { | ||||||
|  | 	return new OpacityBy(_duration, -_deltaVal); | ||||||
|  | } | ||||||
|  | @ -0,0 +1,19 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | e2d::OpacityTo::OpacityTo(double duration, double opacity) : | ||||||
|  | 	OpacityBy(duration, 0) | ||||||
|  | { | ||||||
|  | 	_endVal = opacity; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::OpacityTo * e2d::OpacityTo::clone() const | ||||||
|  | { | ||||||
|  | 	return new OpacityTo(_duration, _endVal); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::OpacityTo::_init() | ||||||
|  | { | ||||||
|  | 	OpacityBy::_init(); | ||||||
|  | 	_deltaVal = _endVal - _startVal; | ||||||
|  | } | ||||||
|  | @ -0,0 +1,40 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | e2d::RotateBy::RotateBy(double duration, double rotation) : | ||||||
|  | 	ActionGradual(duration) | ||||||
|  | { | ||||||
|  | 	_deltaVal = rotation; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::RotateBy::_init() | ||||||
|  | { | ||||||
|  | 	ActionGradual::_init(); | ||||||
|  | 	if (_target) | ||||||
|  | 	{ | ||||||
|  | 		_startVal = _target->getRotation(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::RotateBy::_update() | ||||||
|  | { | ||||||
|  | 	ActionGradual::_update(); | ||||||
|  | 
 | ||||||
|  | 	if (_target == nullptr) | ||||||
|  | 	{ | ||||||
|  | 		this->stop(); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	_target->setRotation(_startVal + _deltaVal * _delta); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::RotateBy * e2d::RotateBy::clone() const | ||||||
|  | { | ||||||
|  | 	return new RotateBy(_duration, _deltaVal); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::RotateBy * e2d::RotateBy::reverse() const | ||||||
|  | { | ||||||
|  | 	return new RotateBy(_duration, -_deltaVal); | ||||||
|  | } | ||||||
|  | @ -0,0 +1,19 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | e2d::RotateTo::RotateTo(double duration, double rotation) : | ||||||
|  | 	RotateBy(duration, 0) | ||||||
|  | { | ||||||
|  | 	_endVal = rotation; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::RotateTo * e2d::RotateTo::clone() const | ||||||
|  | { | ||||||
|  | 	return new RotateTo(_duration, _endVal); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::RotateTo::_init() | ||||||
|  | { | ||||||
|  | 	RotateBy::_init(); | ||||||
|  | 	_deltaVal = _endVal - _startVal; | ||||||
|  | } | ||||||
|  | @ -0,0 +1,49 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | e2d::ScaleBy::ScaleBy(double duration, double scale) | ||||||
|  | 	: ActionGradual(duration) | ||||||
|  | { | ||||||
|  | 	_deltaX = scale; | ||||||
|  | 	_deltaY = scale; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::ScaleBy::ScaleBy(double duration, double scaleX, double scaleY) | ||||||
|  | 	: ActionGradual(duration) | ||||||
|  | { | ||||||
|  | 	_deltaX = scaleX; | ||||||
|  | 	_deltaY = scaleY; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::ScaleBy::_init() | ||||||
|  | { | ||||||
|  | 	ActionGradual::_init(); | ||||||
|  | 	if (_target) | ||||||
|  | 	{ | ||||||
|  | 		_startScaleX = _target->getScaleX(); | ||||||
|  | 		_startScaleY = _target->getScaleY(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::ScaleBy::_update() | ||||||
|  | { | ||||||
|  | 	ActionGradual::_update(); | ||||||
|  | 
 | ||||||
|  | 	if (_target == nullptr) | ||||||
|  | 	{ | ||||||
|  | 		this->stop(); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	_target->setScale(_startScaleX + _deltaX * _delta, _startScaleY + _deltaY * _delta); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::ScaleBy * e2d::ScaleBy::clone() const | ||||||
|  | { | ||||||
|  | 	return new ScaleBy(_duration, _deltaX, _deltaY); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::ScaleBy * e2d::ScaleBy::reverse() const | ||||||
|  | { | ||||||
|  | 	return new ScaleBy(_duration, -_deltaX, -_deltaY); | ||||||
|  | } | ||||||
|  | @ -0,0 +1,27 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | 
 | ||||||
|  | e2d::ScaleTo::ScaleTo(double duration, double scale) | ||||||
|  | 	: ScaleBy(duration, 0, 0) | ||||||
|  | { | ||||||
|  | 	_endScaleX = scale; | ||||||
|  | 	_endScaleY = scale; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::ScaleTo::ScaleTo(double duration, double scaleX, double scaleY) | ||||||
|  | 	: ScaleBy(duration, 0, 0) | ||||||
|  | { | ||||||
|  | 	_endScaleX = scaleX; | ||||||
|  | 	_endScaleY = scaleY; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::ScaleTo * e2d::ScaleTo::clone() const | ||||||
|  | { | ||||||
|  | 	return new ScaleTo(_duration, _endScaleX, _endScaleY); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::ScaleTo::_init() | ||||||
|  | { | ||||||
|  | 	ScaleBy::_init(); | ||||||
|  | 	_deltaX = _endScaleX - _startScaleX; | ||||||
|  | 	_deltaY = _endScaleY - _startScaleY; | ||||||
|  | } | ||||||
|  | @ -0,0 +1,149 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | 
 | ||||||
|  | e2d::Sequence::Sequence() | ||||||
|  | 	: _currIndex(0) | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #ifdef HIGHER_THAN_VS2012 | ||||||
|  | e2d::Sequence::Sequence(const std::initializer_list<Action*>& vActions) | ||||||
|  | 	: _currIndex(0) | ||||||
|  | { | ||||||
|  | 	this->add(vActions); | ||||||
|  | } | ||||||
|  | #else | ||||||
|  | e2d::Sequence::Sequence(int number, Action * action1, ...) : | ||||||
|  | 	_currIndex(0) | ||||||
|  | { | ||||||
|  | 	Action ** ppAction = &action1; | ||||||
|  | 
 | ||||||
|  | 	while (number > 0) | ||||||
|  | 	{ | ||||||
|  | 		WARN_IF((*ppAction) == nullptr, "Sequence NULL pointer exception!"); | ||||||
|  | 		this->add(*ppAction); | ||||||
|  | 		ppAction++; | ||||||
|  | 		number--; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | e2d::Sequence::~Sequence() | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Sequence::_init() | ||||||
|  | { | ||||||
|  | 	Action::_init(); | ||||||
|  | 	// 将所有动作与目标绑定
 | ||||||
|  | 	if (_target) | ||||||
|  | 	{ | ||||||
|  | 		for (auto action : _actions) | ||||||
|  | 		{ | ||||||
|  | 			action->_target = _target; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	// 初始化第一个动作
 | ||||||
|  | 	_actions[0]->_init(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Sequence::onDestroy() | ||||||
|  | { | ||||||
|  | 	Action::onDestroy(); | ||||||
|  | 	for (auto action : _actions) | ||||||
|  | 	{ | ||||||
|  | 		SafeRelease(&action); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Sequence::_update() | ||||||
|  | { | ||||||
|  | 	Action::_update(); | ||||||
|  | 
 | ||||||
|  | 	auto &action = _actions[_currIndex]; | ||||||
|  | 	action->_update(); | ||||||
|  | 
 | ||||||
|  | 	if (action->_isDone()) | ||||||
|  | 	{ | ||||||
|  | 		_currIndex++; | ||||||
|  | 		if (_currIndex == _actions.size()) | ||||||
|  | 		{ | ||||||
|  | 			this->stop(); | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		{ | ||||||
|  | 			_actions[_currIndex]->_init(); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Sequence::reset() | ||||||
|  | { | ||||||
|  | 	Action::reset(); | ||||||
|  | 	for (auto action : _actions) | ||||||
|  | 	{ | ||||||
|  | 		action->reset(); | ||||||
|  | 	} | ||||||
|  | 	_currIndex = 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Sequence::_resetTime() | ||||||
|  | { | ||||||
|  | 	for (auto action : _actions) | ||||||
|  | 	{ | ||||||
|  | 		action->_resetTime(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Sequence::add(Action * action) | ||||||
|  | { | ||||||
|  | 	if (action) | ||||||
|  | 	{ | ||||||
|  | 		_actions.push_back(action); | ||||||
|  | 		action->retain(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #ifdef HIGHER_THAN_VS2012 | ||||||
|  | void e2d::Sequence::add(const std::initializer_list<Action*>& vActions) | ||||||
|  | { | ||||||
|  | 	for (const auto &action : vActions) | ||||||
|  | 	{ | ||||||
|  | 		this->add(action); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | #else | ||||||
|  | void e2d::Sequence::add(int number, Action * action, ...) | ||||||
|  | { | ||||||
|  | 	Action ** ppAction = &action; | ||||||
|  | 
 | ||||||
|  | 	while (number > 0) | ||||||
|  | 	{ | ||||||
|  | 		WARN_IF((*ppAction) == nullptr, "Sequence NULL pointer exception!"); | ||||||
|  | 		this->add(*ppAction); | ||||||
|  | 		ppAction++; | ||||||
|  | 		number--; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | e2d::Sequence * e2d::Sequence::clone() const | ||||||
|  | { | ||||||
|  | 	auto a = new Sequence(); | ||||||
|  | 	for (auto action : _actions) | ||||||
|  | 	{ | ||||||
|  | 		a->add(action->clone()); | ||||||
|  | 	} | ||||||
|  | 	return a; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::Sequence * e2d::Sequence::reverse() const | ||||||
|  | { | ||||||
|  | 	auto a = new Sequence(); | ||||||
|  | 	for (auto action : _actions) | ||||||
|  | 	{ | ||||||
|  | 		a->add(action->reverse()); | ||||||
|  | 	} | ||||||
|  | 	// 将动作顺序逆序排列
 | ||||||
|  | 	a->_actions.reserve(_actions.size()); | ||||||
|  | 	return a; | ||||||
|  | } | ||||||
|  | @ -0,0 +1,147 @@ | ||||||
|  | #include "..\e2daction.h" | ||||||
|  | 
 | ||||||
|  | e2d::Spawn::Spawn() | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #ifdef HIGHER_THAN_VS2012 | ||||||
|  | e2d::Spawn::Spawn(const std::initializer_list<Action*>& vActions) | ||||||
|  | { | ||||||
|  | 	this->add(vActions); | ||||||
|  | } | ||||||
|  | #else | ||||||
|  | e2d::Spawn::Spawn(int number, Action * action1, ...) : | ||||||
|  | 	_currIndex(0) | ||||||
|  | { | ||||||
|  | 	Action ** ppAction = &action1; | ||||||
|  | 
 | ||||||
|  | 	while (number > 0) | ||||||
|  | 	{ | ||||||
|  | 		WARN_IF((*ppAction) == nullptr, "Spawn NULL pointer exception!"); | ||||||
|  | 		this->add(*ppAction); | ||||||
|  | 		ppAction++; | ||||||
|  | 		number--; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | e2d::Spawn::~Spawn() | ||||||
|  | { | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Spawn::_init() | ||||||
|  | { | ||||||
|  | 	Action::_init(); | ||||||
|  | 
 | ||||||
|  | 	if (_target) | ||||||
|  | 	{ | ||||||
|  | 		for (auto action : _actions) | ||||||
|  | 		{ | ||||||
|  | 			action->_target = _target; | ||||||
|  | 			action->_init(); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Spawn::onDestroy() | ||||||
|  | { | ||||||
|  | 	Action::onDestroy(); | ||||||
|  | 	for (auto action : _actions) | ||||||
|  | 	{ | ||||||
|  | 		SafeRelease(&action); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Spawn::_update() | ||||||
|  | { | ||||||
|  | 	Action::_update(); | ||||||
|  | 
 | ||||||
|  | 	size_t doneNum = 0; | ||||||
|  | 	for (auto action : _actions) | ||||||
|  | 	{ | ||||||
|  | 		if (action->_isDone()) | ||||||
|  | 		{ | ||||||
|  | 			doneNum++; | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		{ | ||||||
|  | 			action->_update(); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if (doneNum == _actions.size()) | ||||||
|  | 	{ | ||||||
|  | 		this->stop(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Spawn::reset() | ||||||
|  | { | ||||||
|  | 	Action::reset(); | ||||||
|  | 	for (auto action : _actions) | ||||||
|  | 	{ | ||||||
|  | 		action->reset(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Spawn::_resetTime() | ||||||
|  | { | ||||||
|  | 	for (auto action : _actions) | ||||||
|  | 	{ | ||||||
|  | 		action->_resetTime(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void e2d::Spawn::add(Action * action) | ||||||
|  | { | ||||||
|  | 	if (action) | ||||||
|  | 	{ | ||||||
|  | 		_actions.push_back(action); | ||||||
|  | 		action->retain(); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | #ifdef HIGHER_THAN_VS2012 | ||||||
|  | void e2d::Spawn::add(const std::initializer_list<Action*>& vActions) | ||||||
|  | { | ||||||
|  | 	for (const auto &action : vActions) | ||||||
|  | 	{ | ||||||
|  | 		this->add(action); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | #else | ||||||
|  | void e2d::Spawn::add(int number, Action * action, ...) | ||||||
|  | { | ||||||
|  | 	Action ** ppAction = &action; | ||||||
|  | 
 | ||||||
|  | 	while (number > 0) | ||||||
|  | 	{ | ||||||
|  | 		WARN_IF((*ppAction) == nullptr, "Spawn NULL pointer exception!"); | ||||||
|  | 		this->add(*ppAction); | ||||||
|  | 		ppAction++; | ||||||
|  | 		number--; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | e2d::Spawn * e2d::Spawn::clone() const | ||||||
|  | { | ||||||
|  | 	auto a = new Spawn(); | ||||||
|  | 	for (auto action : _actions) | ||||||
|  | 	{ | ||||||
|  | 		a->add(action->clone()); | ||||||
|  | 	} | ||||||
|  | 	return a; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | e2d::Spawn * e2d::Spawn::reverse() const | ||||||
|  | { | ||||||
|  | 	auto a = new Spawn(); | ||||||
|  | 	for (auto action : _actions) | ||||||
|  | 	{ | ||||||
|  | 		a->add(action->reverse()); | ||||||
|  | 	} | ||||||
|  | 	// ½«¶¯×÷˳ÐòÄæÐòÅÅÁÐ
 | ||||||
|  | 	a->_actions.reserve(_actions.size()); | ||||||
|  | 	return a; | ||||||
|  | } | ||||||
|  | @ -91,7 +91,7 @@ void e2d::Scene::showCollider(bool visiable) | ||||||
| 	_bColliderVisiable = visiable; | 	_bColliderVisiable = visiable; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Scene::destroy() | void e2d::Scene::onDestroy() | ||||||
| { | { | ||||||
| 	SafeRelease(&_pRoot); | 	SafeRelease(&_pRoot); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,8 +1,8 @@ | ||||||
| #include "..\e2dmanager.h" | #include "..\e2dmanager.h" | ||||||
| #include "..\e2daction.h" | #include "..\e2daction.h" | ||||||
| 
 | 
 | ||||||
| static std::vector<e2d::ActionBase*> s_vActions; | static std::vector<e2d::Action*> s_vActions; | ||||||
| static std::vector<e2d::ActionBase*> s_vRunningActions; | static std::vector<e2d::Action*> s_vRunningActions; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| void e2d::ActionManager::__update() | void e2d::ActionManager::__update() | ||||||
|  | @ -19,7 +19,7 @@ void e2d::ActionManager::__update() | ||||||
| 		{ | 		{ | ||||||
| 			// ¶¯×÷ÒѾ½áÊø
 | 			// ¶¯×÷ÒѾ½áÊø
 | ||||||
| 			action->release(); | 			action->release(); | ||||||
| 			action->_pTarget = nullptr; | 			action->_target = nullptr; | ||||||
| 			s_vRunningActions.erase(s_vRunningActions.begin() + i); | 			s_vRunningActions.erase(s_vRunningActions.begin() + i); | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
|  | @ -33,7 +33,7 @@ void e2d::ActionManager::__update() | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::ActionManager::__add(ActionBase * action) | void e2d::ActionManager::__add(Action * action) | ||||||
| { | { | ||||||
| 	if (action) | 	if (action) | ||||||
| 	{ | 	{ | ||||||
|  | @ -41,7 +41,7 @@ void e2d::ActionManager::__add(ActionBase * action) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::ActionManager::__remove(ActionBase * action) | void e2d::ActionManager::__remove(Action * action) | ||||||
| { | { | ||||||
| 	for (size_t i = 0; i < s_vActions.size();) | 	for (size_t i = 0; i < s_vActions.size();) | ||||||
| 	{ | 	{ | ||||||
|  | @ -98,16 +98,28 @@ void e2d::ActionManager::__stopAllBindedWith(Node * target) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::ActionManager::start(ActionBase * action, Node * target, bool paused) | void e2d::ActionManager::start(Action * action, Node * target, bool paused) | ||||||
| { | { | ||||||
| 	WARN_IF(action == nullptr, "ActionBase NULL pointer exception!"); | 	WARN_IF(action == nullptr, "Action NULL pointer exception!"); | ||||||
| 	WARN_IF(target == nullptr, "Target node NULL pointer exception!"); | 	WARN_IF(target == nullptr, "Target node NULL pointer exception!"); | ||||||
| 
 | 
 | ||||||
| 	if (action && target) | 	if (action && target) | ||||||
| 	{ | 	{ | ||||||
|  | 		ASSERT([](Action * newAction) | ||||||
|  | 		{ | ||||||
|  | 			for (const auto& action : s_vRunningActions) | ||||||
|  | 			{ | ||||||
|  | 				if (newAction == action) | ||||||
|  | 				{ | ||||||
|  | 					return false; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			return true; | ||||||
|  | 		}(action), "action already be added!"); | ||||||
|  | 
 | ||||||
| 		action->_startWithTarget(target); | 		action->_startWithTarget(target); | ||||||
| 		action->retain(); | 		action->retain(); | ||||||
| 		action->_bRunning = !paused; | 		action->_running = !paused; | ||||||
| 		s_vRunningActions.push_back(action); | 		s_vRunningActions.push_back(action); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | @ -199,9 +211,9 @@ void e2d::ActionManager::stopAll() | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::vector<e2d::ActionBase*> e2d::ActionManager::get(const String& strActionName) | std::vector<e2d::Action*> e2d::ActionManager::get(const String& strActionName) | ||||||
| { | { | ||||||
| 	std::vector<ActionBase*> vActions; | 	std::vector<Action*> vActions; | ||||||
| 	for (auto action : s_vActions) | 	for (auto action : s_vActions) | ||||||
| 	{ | 	{ | ||||||
| 		if (action->getName() == strActionName) | 		if (action->getName() == strActionName) | ||||||
|  | @ -212,7 +224,7 @@ std::vector<e2d::ActionBase*> e2d::ActionManager::get(const String& strActionNam | ||||||
| 	return std::move(vActions); | 	return std::move(vActions); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::vector<e2d::ActionBase*> e2d::ActionManager::getAll() | std::vector<e2d::Action*> e2d::ActionManager::getAll() | ||||||
| { | { | ||||||
| 	return s_vActions; | 	return s_vActions; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -21,7 +21,7 @@ void e2d::ObjectManager::__update() | ||||||
| 	{ | 	{ | ||||||
| 		if ((*iter)->getRefCount() <= 0) | 		if ((*iter)->getRefCount() <= 0) | ||||||
| 		{ | 		{ | ||||||
| 			(*iter)->destroy(); | 			(*iter)->onDestroy(); | ||||||
| 			delete (*iter); | 			delete (*iter); | ||||||
| 			iter = s_vObjectPool.erase(iter); | 			iter = s_vObjectPool.erase(iter); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| e2d::Button::Button() | e2d::Button::Button() | ||||||
| 	: _Callback(nullptr) | 	: _func(nullptr) | ||||||
| 	, _eBtnState(ButtonState::NORMAL) | 	, _eBtnState(ButtonState::NORMAL) | ||||||
| 	, _bEnable(true) | 	, _bEnable(true) | ||||||
| 	, _bIsSelected(false) | 	, _bIsSelected(false) | ||||||
|  | @ -17,7 +17,7 @@ e2d::Button::Button() | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Button::Button(Node * normal, const Function& func) | e2d::Button::Button(Node * normal, const Function& func) | ||||||
| 	: _Callback(nullptr) | 	: _func(nullptr) | ||||||
| 	, _eBtnState(ButtonState::NORMAL) | 	, _eBtnState(ButtonState::NORMAL) | ||||||
| 	, _bEnable(true) | 	, _bEnable(true) | ||||||
| 	, _bIsSelected(false) | 	, _bIsSelected(false) | ||||||
|  | @ -31,7 +31,7 @@ e2d::Button::Button(Node * normal, const Function& func) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Button::Button(Node * normal, Node * selected, const Function& func) | e2d::Button::Button(Node * normal, Node * selected, const Function& func) | ||||||
| 	: _Callback(nullptr) | 	: _func(nullptr) | ||||||
| 	, _eBtnState(ButtonState::NORMAL) | 	, _eBtnState(ButtonState::NORMAL) | ||||||
| 	, _bEnable(true) | 	, _bEnable(true) | ||||||
| 	, _bIsSelected(false) | 	, _bIsSelected(false) | ||||||
|  | @ -46,7 +46,7 @@ e2d::Button::Button(Node * normal, Node * selected, const Function& func) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, const Function& func) | e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, const Function& func) | ||||||
| 	: _Callback(nullptr) | 	: _func(nullptr) | ||||||
| 	, _eBtnState(ButtonState::NORMAL) | 	, _eBtnState(ButtonState::NORMAL) | ||||||
| 	, _bEnable(true) | 	, _bEnable(true) | ||||||
| 	, _bIsSelected(false) | 	, _bIsSelected(false) | ||||||
|  | @ -62,7 +62,7 @@ e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, const Func | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, const Function& func) | e2d::Button::Button(Node * normal, Node * mouseover, Node * selected, Node * disabled, const Function& func) | ||||||
| 	: _Callback(nullptr) | 	: _func(nullptr) | ||||||
| 	, _eBtnState(ButtonState::NORMAL) | 	, _eBtnState(ButtonState::NORMAL) | ||||||
| 	, _bEnable(true) | 	, _bEnable(true) | ||||||
| 	, _bIsSelected(false) | 	, _bIsSelected(false) | ||||||
|  | @ -174,7 +174,7 @@ void e2d::Button::setClickFunc(const Function& func) | ||||||
| { | { | ||||||
| 	WARN_IF(_pNormal == nullptr, "Button cannot work without anything to show. Please set its normal displayed."); | 	WARN_IF(_pNormal == nullptr, "Button cannot work without anything to show. Please set its normal displayed."); | ||||||
| 	 | 	 | ||||||
| 	_Callback = func; | 	_func = func; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Button::onFixedUpdate() | void e2d::Button::onFixedUpdate() | ||||||
|  | @ -277,8 +277,8 @@ void e2d::Button::_updateVisiable() | ||||||
| 
 | 
 | ||||||
| void e2d::Button::_runCallback() | void e2d::Button::_runCallback() | ||||||
| { | { | ||||||
| 	if (_Callback) | 	if (_func) | ||||||
| 	{ | 	{ | ||||||
| 		_Callback(); | 		_func(); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -311,8 +311,8 @@ void e2d::ButtonToggle::_runCallback() | ||||||
| 	_bState = !_bState; | 	_bState = !_bState; | ||||||
| 	_updateState(); | 	_updateState(); | ||||||
| 
 | 
 | ||||||
| 	if (_Callback) | 	if (_func) | ||||||
| 	{ | 	{ | ||||||
| 		_Callback(); | 		_func(); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -240,7 +240,7 @@ bool e2d::Node::isVisiable() const | ||||||
| 
 | 
 | ||||||
| e2d::String e2d::Node::getName() const | e2d::String e2d::Node::getName() const | ||||||
| { | { | ||||||
| 	return _sName; | 	return _name; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| unsigned int e2d::Node::getHashName() const | unsigned int e2d::Node::getHashName() const | ||||||
|  | @ -676,7 +676,7 @@ std::vector<e2d::Node*> e2d::Node::getChildren(const String& name) const | ||||||
| 	for (auto child : _vChildren) | 	for (auto child : _vChildren) | ||||||
| 	{ | 	{ | ||||||
| 		// 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度
 | 		// 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度
 | ||||||
| 		if (child->_nHashName == hash && child->_sName == name) | 		if (child->_nHashName == hash && child->_name == name) | ||||||
| 		{ | 		{ | ||||||
| 			vChildren.push_back(child); | 			vChildren.push_back(child); | ||||||
| 		} | 		} | ||||||
|  | @ -691,7 +691,7 @@ e2d::Node * e2d::Node::getChild(const String& name) const | ||||||
| 	for (auto child : _vChildren) | 	for (auto child : _vChildren) | ||||||
| 	{ | 	{ | ||||||
| 		// 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度
 | 		// 不同的名称可能会有相同的 Hash 值,但是先比较 Hash 可以提升搜索速度
 | ||||||
| 		if (child->_nHashName == hash && child->_sName == name) | 		if (child->_nHashName == hash && child->_name == name) | ||||||
| 		{ | 		{ | ||||||
| 			return child; | 			return child; | ||||||
| 		} | 		} | ||||||
|  | @ -765,7 +765,7 @@ void e2d::Node::removeChildren(const String& childName) | ||||||
| 	for (size_t i = 0; i < size; i++) | 	for (size_t i = 0; i < size; i++) | ||||||
| 	{ | 	{ | ||||||
| 		auto child = _vChildren[i]; | 		auto child = _vChildren[i]; | ||||||
| 		if (child->_nHashName == hash && child->_sName == childName) | 		if (child->_nHashName == hash && child->_name == childName) | ||||||
| 		{ | 		{ | ||||||
| 			_vChildren.erase(_vChildren.begin() + i); | 			_vChildren.erase(_vChildren.begin() + i); | ||||||
| 			child->_pParent = nullptr; | 			child->_pParent = nullptr; | ||||||
|  | @ -789,7 +789,7 @@ void e2d::Node::clearAllChildren() | ||||||
| 	_vChildren.clear(); | 	_vChildren.clear(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::runAction(ActionBase * action) | void e2d::Node::runAction(Action * action) | ||||||
| { | { | ||||||
| 	if (this != action->getTarget()) | 	if (this != action->getTarget()) | ||||||
| 	{ | 	{ | ||||||
|  | @ -838,7 +838,7 @@ void e2d::Node::stopAction(const String& strActionName) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::ActionBase * e2d::Node::getAction(const String& strActionName) | e2d::Action * e2d::Node::getAction(const String& strActionName) | ||||||
| { | { | ||||||
| 	auto actions = ActionManager::get(strActionName); | 	auto actions = ActionManager::get(strActionName); | ||||||
| 	for (auto action : actions) | 	for (auto action : actions) | ||||||
|  | @ -851,9 +851,9 @@ e2d::ActionBase * e2d::Node::getAction(const String& strActionName) | ||||||
| 	return nullptr; | 	return nullptr; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::vector<e2d::ActionBase*> e2d::Node::getActions(const String& strActionName) | std::vector<e2d::Action*> e2d::Node::getActions(const String& strActionName) | ||||||
| { | { | ||||||
| 	std::vector<ActionBase*>::iterator iter; | 	std::vector<Action*>::iterator iter; | ||||||
| 	auto actions = ActionManager::get(strActionName); | 	auto actions = ActionManager::get(strActionName); | ||||||
| 	for (iter = actions.begin(); iter != actions.end();) | 	for (iter = actions.begin(); iter != actions.end();) | ||||||
| 	{ | 	{ | ||||||
|  | @ -983,7 +983,7 @@ void e2d::Node::setDefaultColliderEnable(bool enable) | ||||||
| 	s_fDefaultColliderEnabled = enable; | 	s_fDefaultColliderEnabled = enable; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Node::destroy() | void e2d::Node::onDestroy() | ||||||
| { | { | ||||||
| 	ActionManager::__clearAllBindedWith(this); | 	ActionManager::__clearAllBindedWith(this); | ||||||
| 	ColliderManager::__removeCollider(_pCollider); | 	ColliderManager::__removeCollider(_pCollider); | ||||||
|  | @ -1017,10 +1017,10 @@ void e2d::Node::setName(const String& name) | ||||||
| { | { | ||||||
| 	WARN_IF(name.isEmpty(), "Invalid Node name."); | 	WARN_IF(name.isEmpty(), "Invalid Node name."); | ||||||
| 
 | 
 | ||||||
| 	if (!name.isEmpty() && _sName != name) | 	if (!name.isEmpty() && _name != name) | ||||||
| 	{ | 	{ | ||||||
| 		// 保存节点名
 | 		// 保存节点名
 | ||||||
| 		_sName = name; | 		_name = name; | ||||||
| 		// 保存节点 Hash 名
 | 		// 保存节点 Hash 名
 | ||||||
| 		_nHashName = name.getHashCode(); | 		_nHashName = name.getHashCode(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -125,8 +125,8 @@ void e2d::Sprite::onRender() | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::Sprite::destroy() | void e2d::Sprite::onDestroy() | ||||||
| { | { | ||||||
| 	Node::destroy(); | 	Node::onDestroy(); | ||||||
| 	SafeRelease(&_pImage); | 	SafeRelease(&_pImage); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
| e2d::TransitionBase::TransitionBase(double duration) | e2d::TransitionBase::TransitionBase(double duration) | ||||||
| 	: _bEnd(false) | 	: _bEnd(false) | ||||||
| 	, _fLast(0) | 	, _fLast(0) | ||||||
| 	, _fRateOfProgress(0) | 	, _delta(0) | ||||||
| 	, _pPrevScene(nullptr) | 	, _pPrevScene(nullptr) | ||||||
| 	, _pNextScene(nullptr) | 	, _pNextScene(nullptr) | ||||||
| 	, _pPrevLayer(nullptr) | 	, _pPrevLayer(nullptr) | ||||||
|  | @ -13,7 +13,7 @@ e2d::TransitionBase::TransitionBase(double duration) | ||||||
| 	, _sPrevLayerParam() | 	, _sPrevLayerParam() | ||||||
| 	, _sNextLayerParam() | 	, _sNextLayerParam() | ||||||
| { | { | ||||||
| 	_fDuration = max(duration, 0); | 	_duration = max(duration, 0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| e2d::TransitionBase::~TransitionBase() | e2d::TransitionBase::~TransitionBase() | ||||||
|  | @ -27,7 +27,7 @@ bool e2d::TransitionBase::isDone() | ||||||
| 	return _bEnd; | 	return _bEnd; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::TransitionBase::destroy() | void e2d::TransitionBase::onDestroy() | ||||||
| { | { | ||||||
| 	SafeRelease(&_pPrevScene); | 	SafeRelease(&_pPrevScene); | ||||||
| 	SafeRelease(&_pNextScene); | 	SafeRelease(&_pNextScene); | ||||||
|  | @ -61,13 +61,13 @@ void e2d::TransitionBase::_init(Scene * prev, Scene * next) | ||||||
| void e2d::TransitionBase::_update() | void e2d::TransitionBase::_update() | ||||||
| { | { | ||||||
| 	// 计算动画进度
 | 	// 计算动画进度
 | ||||||
| 	if (_fDuration == 0) | 	if (_duration == 0) | ||||||
| 	{ | 	{ | ||||||
| 		_fRateOfProgress = 1; | 		_delta = 1; | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		_fRateOfProgress = min((Time::getTotalTime() - _fLast) / _fDuration, 1); | 		_delta = min((Time::getTotalTime() - _fLast) / _duration, 1); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	this->_updateCustom(); | 	this->_updateCustom(); | ||||||
|  |  | ||||||
|  | @ -15,10 +15,10 @@ void e2d::TransitionEmerge::_init(Scene * prev, Scene * next) | ||||||
| 
 | 
 | ||||||
| void e2d::TransitionEmerge::_updateCustom() | void e2d::TransitionEmerge::_updateCustom() | ||||||
| { | { | ||||||
| 	_sPrevLayerParam.opacity = float(1 - _fRateOfProgress); | 	_sPrevLayerParam.opacity = float(1 - _delta); | ||||||
| 	_sNextLayerParam.opacity = float(_fRateOfProgress); | 	_sNextLayerParam.opacity = float(_delta); | ||||||
| 
 | 
 | ||||||
| 	if (_fRateOfProgress >= 1) | 	if (_delta >= 1) | ||||||
| 	{ | 	{ | ||||||
| 		this->_stop(); | 		this->_stop(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -23,12 +23,12 @@ void e2d::TransitionFade::_init(Scene * prev, Scene * next) | ||||||
| 	if (_pPrevScene) | 	if (_pPrevScene) | ||||||
| 	{ | 	{ | ||||||
| 		_bFadeOutTransioning = true; | 		_bFadeOutTransioning = true; | ||||||
| 		_fDuration = _fFadeOutDuration; | 		_duration = _fFadeOutDuration; | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		_bFadeOutTransioning = false; | 		_bFadeOutTransioning = false; | ||||||
| 		_fDuration = _fFadeInDuration; | 		_duration = _fFadeInDuration; | ||||||
| 	} | 	} | ||||||
| 	_sPrevLayerParam.opacity = 1; | 	_sPrevLayerParam.opacity = 1; | ||||||
| 	_sNextLayerParam.opacity = 0; | 	_sNextLayerParam.opacity = 0; | ||||||
|  | @ -38,18 +38,18 @@ void e2d::TransitionFade::_updateCustom() | ||||||
| { | { | ||||||
| 	if (_bFadeOutTransioning) | 	if (_bFadeOutTransioning) | ||||||
| 	{ | 	{ | ||||||
| 		_sPrevLayerParam.opacity = float(1 - _fRateOfProgress); | 		_sPrevLayerParam.opacity = float(1 - _delta); | ||||||
| 		if (_fRateOfProgress >= 1) | 		if (_delta >= 1) | ||||||
| 		{ | 		{ | ||||||
| 			_bFadeOutTransioning = false; | 			_bFadeOutTransioning = false; | ||||||
| 			_fDuration = _fFadeInDuration; | 			_duration = _fFadeInDuration; | ||||||
| 			_fLast = Time::getTotalTime(); | 			_fLast = Time::getTotalTime(); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		_sNextLayerParam.opacity = float(_fRateOfProgress); | 		_sNextLayerParam.opacity = float(_delta); | ||||||
| 		if (_fRateOfProgress >= 1) | 		if (_delta >= 1) | ||||||
| 		{ | 		{ | ||||||
| 			this->_stop(); | 			this->_stop(); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -42,14 +42,14 @@ void e2d::TransitionMove::_updateCustom() | ||||||
| { | { | ||||||
| 	if (_pPrevScene) | 	if (_pPrevScene) | ||||||
| 	{ | 	{ | ||||||
| 		_pPrevScene->getRoot()->setPos(_Vector * _fRateOfProgress); | 		_pPrevScene->getRoot()->setPos(_Vector * _delta); | ||||||
| 	} | 	} | ||||||
| 	if (_pNextScene) | 	if (_pNextScene) | ||||||
| 	{ | 	{ | ||||||
| 		_pNextScene->getRoot()->setPos(_NextPos + _Vector * _fRateOfProgress); | 		_pNextScene->getRoot()->setPos(_NextPos + _Vector * _delta); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (_fRateOfProgress >= 1) | 	if (_delta >= 1) | ||||||
| 	{ | 	{ | ||||||
| 		this->_stop(); | 		this->_stop(); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
							
								
								
									
										532
									
								
								core/e2daction.h
								
								
								
								
							
							
						
						
									
										532
									
								
								core/e2daction.h
								
								
								
								
							|  | @ -6,166 +6,24 @@ namespace e2d | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class ActionManager; | class ActionManager; | ||||||
| class ActionBase; | class Loop; | ||||||
| class ActionMoveBy; | class Sequence; | ||||||
| class ActionMoveTo; | class Spawn; | ||||||
| class ActionScaleBy; |  | ||||||
| class ActionScaleTo; |  | ||||||
| class ActionOpacityBy; |  | ||||||
| class ActionOpacityTo; |  | ||||||
| class ActionFadeIn; |  | ||||||
| class ActionFadeOut; |  | ||||||
| class ActionRotateBy; |  | ||||||
| class ActionRotateTo; |  | ||||||
| class ActionTwo; |  | ||||||
| class ActionDelay; |  | ||||||
| class ActionLoop; |  | ||||||
| class ActionFunc; |  | ||||||
| class ActionSequence; |  | ||||||
| class Animation; |  | ||||||
| 
 |  | ||||||
| // 动作生成器
 |  | ||||||
| class Action |  | ||||||
| { |  | ||||||
| public: |  | ||||||
| 	// 创建相对位移动画
 |  | ||||||
| 	static e2d::ActionMoveBy* MoveBy( |  | ||||||
| 		double duration,	/* 动画持续时长 */ |  | ||||||
| 		Vector vector		/* 位移向量 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建位移动画
 |  | ||||||
| 	static e2d::ActionMoveTo* MoveTo( |  | ||||||
| 		double duration,	/* 动画持续时长 */ |  | ||||||
| 		Point pos			/* 位移至目标点的坐标 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建相对缩放动画
 |  | ||||||
| 	static e2d::ActionScaleBy* ScaleBy( |  | ||||||
| 		double duration,	/* 动画持续时长 */ |  | ||||||
| 		double scale		/* 缩放比例变化 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建相对缩放动画
 |  | ||||||
| 	static e2d::ActionScaleBy* ScaleBy( |  | ||||||
| 		double duration,	/* 动画持续时长 */ |  | ||||||
| 		double scaleX,		/* 横向缩放比例变化 */ |  | ||||||
| 		double scaleY		/* 纵向缩放比例变化 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建缩放动画
 |  | ||||||
| 	static e2d::ActionScaleTo* ScaleTo( |  | ||||||
| 		double duration,	/* 动画持续时长 */ |  | ||||||
| 		double scale		/* 缩放至目标比例 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建缩放动画
 |  | ||||||
| 	static e2d::ActionScaleTo* ScaleTo( |  | ||||||
| 		double duration,	/* 动画持续时长 */ |  | ||||||
| 		double scaleX,		/* 横向缩放至目标比例 */ |  | ||||||
| 		double scaleY		/* 纵向缩放至目标比例 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建透明度相对渐变动画
 |  | ||||||
| 	static e2d::ActionOpacityBy* OpacityBy( |  | ||||||
| 		double duration,	/* 动画持续时长 */ |  | ||||||
| 		double opacity		/* 透明度相对变化值 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建透明度渐变动画
 |  | ||||||
| 	static e2d::ActionOpacityTo* OpacityTo( |  | ||||||
| 		double duration,	/* 动画持续时长 */ |  | ||||||
| 		double opacity		/* 透明度渐变至目标值 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建淡入动画
 |  | ||||||
| 	static e2d::ActionFadeIn* FadeIn( |  | ||||||
| 		double duration		/* 动画持续时长 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建淡出动画
 |  | ||||||
| 	static e2d::ActionFadeOut* FadeOut( |  | ||||||
| 		double duration		/* 动画持续时长 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建相对旋转动画
 |  | ||||||
| 	static e2d::ActionRotateBy* RotateBy( |  | ||||||
| 		double duration,	/* 动画持续时长 */ |  | ||||||
| 		double rotation		/* 旋转角度变化值 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建旋转动画
 |  | ||||||
| 	static e2d::ActionRotateTo* RotateTo( |  | ||||||
| 		double duration,	/* 动画持续时长 */ |  | ||||||
| 		double rotation		/* 旋转角度至目标值 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建两个动作的连续动作
 |  | ||||||
| 	static e2d::ActionTwo* Two( |  | ||||||
| 		ActionBase * pActionFirst,		/* 第一个动作 */ |  | ||||||
| 		ActionBase * pActionSecond,		/* 第二个动作 */ |  | ||||||
| 		bool bAtSameTime = false		/* 同时开始 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建延时动作
 |  | ||||||
| 	static e2d::ActionDelay* Delay( |  | ||||||
| 		double duration		/* 延迟时长(秒) */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建循环动作
 |  | ||||||
| 	static e2d::ActionLoop* Loop( |  | ||||||
| 		ActionBase * action,	/* 执行循环的动作 */ |  | ||||||
| 		int times = -1			/* 循环次数 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建执行函数对象的动作
 |  | ||||||
| 	static e2d::ActionFunc* Func( |  | ||||||
| 		const Function& func		/* 函数对象 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| #ifdef HIGHER_THAN_VS2012 |  | ||||||
| 	// 创建顺序动作
 |  | ||||||
| 	static e2d::ActionSequence* Sequence( |  | ||||||
| 		const std::initializer_list<ActionBase*>& vActions	/* 动作列表 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建特定帧间隔的帧动画
 |  | ||||||
| 	static e2d::Animation* Animation( |  | ||||||
| 		double interval,									/* 帧间隔(秒) */ |  | ||||||
| 		const std::initializer_list<Image*>& vFrames		/* 关键帧列表 */ |  | ||||||
| 	); |  | ||||||
| #else |  | ||||||
| 	// 创建顺序动作
 |  | ||||||
| 	static e2d::ActionSequence* Sequence( |  | ||||||
| 		int number,			/* 动作数量 */ |  | ||||||
| 		ActionBase * action1,	/* 第一个动作 */ |  | ||||||
| 		... |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 创建特定帧间隔的帧动画
 |  | ||||||
| 	static e2d::Animation* Animation( |  | ||||||
| 		double interval,	/* 帧间隔(秒) */ |  | ||||||
| 		int number,			/* 帧数量 */ |  | ||||||
| 		Image * frame,		/* 第一帧 */ |  | ||||||
| 		... |  | ||||||
| 	); |  | ||||||
| #endif |  | ||||||
| }; |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 基础动作
 | // 基础动作
 | ||||||
| class ActionBase : | class Action : | ||||||
| 	public Object | 	public Object | ||||||
| { | { | ||||||
| 	friend ActionManager; | 	friend ActionManager; | ||||||
| 	friend ActionTwo; | 	friend Loop; | ||||||
| 	friend ActionLoop; | 	friend Sequence; | ||||||
| 	friend ActionSequence; | 	friend Spawn; | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
| 	ActionBase(); | 	Action(); | ||||||
| 
 | 
 | ||||||
| 	virtual ~ActionBase(); | 	virtual ~Action(); | ||||||
| 
 | 
 | ||||||
| 	// 获取动作运行状态
 | 	// 获取动作运行状态
 | ||||||
| 	virtual bool isRunning(); | 	virtual bool isRunning(); | ||||||
|  | @ -188,10 +46,10 @@ public: | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取动作的拷贝
 | 	// 获取动作的拷贝
 | ||||||
| 	virtual ActionBase * clone() const = 0; | 	virtual Action * clone() const = 0; | ||||||
| 
 | 
 | ||||||
| 	// 获取动作的倒转
 | 	// 获取动作的倒转
 | ||||||
| 	virtual ActionBase * reverse() const; | 	virtual Action * reverse() const; | ||||||
| 
 | 
 | ||||||
| 	// 重置动作
 | 	// 重置动作
 | ||||||
| 	virtual void reset(); | 	virtual void reset(); | ||||||
|  | @ -200,7 +58,7 @@ public: | ||||||
| 	virtual Node * getTarget(); | 	virtual Node * getTarget(); | ||||||
| 
 | 
 | ||||||
| 	// 销毁对象
 | 	// 销毁对象
 | ||||||
| 	virtual void destroy() override; | 	virtual void onDestroy() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动作
 | 	// 初始化动作
 | ||||||
|  | @ -221,19 +79,18 @@ protected: | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	String	_sName; | 	String	_name; | ||||||
| 	bool	_bRunning; | 	bool	_running; | ||||||
| 	bool	_bEnding; | 	bool	_done; | ||||||
| 	bool	_bInit; | 	bool	_initialized; | ||||||
| 	Node *	_pTarget; | 	Node *	_target; | ||||||
| 	Scene * _pParentScene; |  | ||||||
| 	double	_fLast; | 	double	_fLast; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 持续动作
 | // 持续动作
 | ||||||
| class ActionGradual : | class ActionGradual : | ||||||
| 	public ActionBase | 	public Action | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建特定时长的持续动画
 | 	// 创建特定时长的持续动画
 | ||||||
|  | @ -249,27 +106,27 @@ protected: | ||||||
| 	virtual void _update() override; | 	virtual void _update() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	double _fDuration; | 	double _duration; | ||||||
| 	double _fRateOfProgress; | 	double _delta; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 相对位移动画
 | // 相对位移动画
 | ||||||
| class ActionMoveBy : | class MoveBy : | ||||||
| 	public ActionGradual | 	public ActionGradual | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建相对位移动画
 | 	// 创建相对位移动画
 | ||||||
| 	ActionMoveBy( | 	MoveBy( | ||||||
| 		double duration,	/* 动画持续时长 */ | 		double duration,	/* 动画持续时长 */ | ||||||
| 		Vector vector		/* 位移向量 */ | 		Vector vector		/* 位移向量 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取该动画的拷贝对象
 | 	// 获取该动画的拷贝对象
 | ||||||
| 	virtual ActionMoveBy * clone() const override; | 	virtual MoveBy * clone() const override; | ||||||
| 
 | 
 | ||||||
| 	// 获取该动画的倒转
 | 	// 获取该动画的倒转
 | ||||||
| 	virtual ActionMoveBy * reverse() const override; | 	virtual MoveBy * reverse() const override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动画
 | 	// 初始化动画
 | ||||||
|  | @ -279,57 +136,57 @@ protected: | ||||||
| 	virtual void _update() override; | 	virtual void _update() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	Point		_BeginPos; | 	Point	_startPos; | ||||||
| 	Vector	_MoveVec; | 	Vector	_deltaPos; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 位移动画
 | // 位移动画
 | ||||||
| class ActionMoveTo : | class MoveTo : | ||||||
| 	public ActionMoveBy | 	public MoveBy | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建位移动画
 | 	// 创建位移动画
 | ||||||
| 	ActionMoveTo( | 	MoveTo( | ||||||
| 		double duration,	/* 动画持续时长 */ | 		double duration,	/* 动画持续时长 */ | ||||||
| 		Point pos			/* 位移至目标点的坐标 */ | 		Point pos			/* 位移至目标点的坐标 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取该动画的拷贝对象
 | 	// 获取该动画的拷贝对象
 | ||||||
| 	virtual ActionMoveTo * clone() const override; | 	virtual MoveTo * clone() const override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动画
 | 	// 初始化动画
 | ||||||
| 	virtual void _init() override; | 	virtual void _init() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	Point _EndPos; | 	Point _endPos; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 相对缩放动画
 | // 相对缩放动画
 | ||||||
| class ActionScaleBy : | class ScaleBy : | ||||||
| 	public ActionGradual | 	public ActionGradual | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建相对缩放动画
 | 	// 创建相对缩放动画
 | ||||||
| 	ActionScaleBy( | 	ScaleBy( | ||||||
| 		double duration,	/* 动画持续时长 */ | 		double duration,	/* 动画持续时长 */ | ||||||
| 		double scale		/* 缩放比例变化 */ | 		double scale		/* 缩放比例变化 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 创建相对缩放动画
 | 	// 创建相对缩放动画
 | ||||||
| 	ActionScaleBy( | 	ScaleBy( | ||||||
| 		double duration,	/* 动画持续时长 */ | 		double duration,	/* 动画持续时长 */ | ||||||
| 		double scaleX,		/* 横向缩放比例变化 */ | 		double scaleX,		/* 横向缩放比例变化 */ | ||||||
| 		double scaleY		/* 纵向缩放比例变化 */ | 		double scaleY		/* 纵向缩放比例变化 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取该动画的拷贝对象
 | 	// 获取该动画的拷贝对象
 | ||||||
| 	virtual ActionScaleBy * clone() const override; | 	virtual ScaleBy * clone() const override; | ||||||
| 
 | 
 | ||||||
| 	// 获取该动画的倒转
 | 	// 获取该动画的倒转
 | ||||||
| 	virtual ActionScaleBy * reverse() const override; | 	virtual ScaleBy * reverse() const override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动画
 | 	// 初始化动画
 | ||||||
|  | @ -339,60 +196,60 @@ protected: | ||||||
| 	virtual void _update() override; | 	virtual void _update() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	double	_nBeginScaleX; | 	double	_startScaleX; | ||||||
| 	double	_nBeginScaleY; | 	double	_startScaleY; | ||||||
| 	double	_nVariationX; | 	double	_deltaX; | ||||||
| 	double	_nVariationY; | 	double	_deltaY; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 缩放动画
 | // 缩放动画
 | ||||||
| class ActionScaleTo : | class ScaleTo : | ||||||
| 	public ActionScaleBy | 	public ScaleBy | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建缩放动画
 | 	// 创建缩放动画
 | ||||||
| 	ActionScaleTo( | 	ScaleTo( | ||||||
| 		double duration,	/* 动画持续时长 */ | 		double duration,	/* 动画持续时长 */ | ||||||
| 		double scale		/* 缩放至目标比例 */ | 		double scale		/* 缩放至目标比例 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 创建缩放动画
 | 	// 创建缩放动画
 | ||||||
| 	ActionScaleTo( | 	ScaleTo( | ||||||
| 		double duration,	/* 动画持续时长 */ | 		double duration,	/* 动画持续时长 */ | ||||||
| 		double scaleX,		/* 横向缩放至目标比例 */ | 		double scaleX,		/* 横向缩放至目标比例 */ | ||||||
| 		double scaleY		/* 纵向缩放至目标比例 */ | 		double scaleY		/* 纵向缩放至目标比例 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取该动画的拷贝对象
 | 	// 获取该动画的拷贝对象
 | ||||||
| 	virtual ActionScaleTo * clone() const override; | 	virtual ScaleTo * clone() const override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动画
 | 	// 初始化动画
 | ||||||
| 	virtual void _init() override; | 	virtual void _init() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	double	_nEndScaleX; | 	double	_endScaleX; | ||||||
| 	double	_nEndScaleY; | 	double	_endScaleY; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 透明度相对渐变动画
 | // 透明度相对渐变动画
 | ||||||
| class ActionOpacityBy : | class OpacityBy : | ||||||
| 	public ActionGradual | 	public ActionGradual | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建透明度相对渐变动画
 | 	// 创建透明度相对渐变动画
 | ||||||
| 	ActionOpacityBy( | 	OpacityBy( | ||||||
| 		double duration,	/* 动画持续时长 */ | 		double duration,	/* 动画持续时长 */ | ||||||
| 		double opacity		/* 透明度相对变化值 */ | 		double opacity		/* 透明度相对变化值 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取该动画的拷贝对象
 | 	// 获取该动画的拷贝对象
 | ||||||
| 	virtual ActionOpacityBy * clone() const override; | 	virtual OpacityBy * clone() const override; | ||||||
| 
 | 
 | ||||||
| 	// 获取该动画的倒转
 | 	// 获取该动画的倒转
 | ||||||
| 	virtual ActionOpacityBy * reverse() const override; | 	virtual OpacityBy * reverse() const override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动画
 | 	// 初始化动画
 | ||||||
|  | @ -402,80 +259,80 @@ protected: | ||||||
| 	virtual void _update() override; | 	virtual void _update() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	double _nBeginVal; | 	double _startVal; | ||||||
| 	double _nVariation; | 	double _deltaVal; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 透明度渐变动画
 | // 透明度渐变动画
 | ||||||
| class ActionOpacityTo : | class OpacityTo : | ||||||
| 	public ActionOpacityBy | 	public OpacityBy | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建透明度渐变动画
 | 	// 创建透明度渐变动画
 | ||||||
| 	ActionOpacityTo( | 	OpacityTo( | ||||||
| 		double duration,	/* 动画持续时长 */ | 		double duration,	/* 动画持续时长 */ | ||||||
| 		double opacity		/* 透明度渐变至目标值 */ | 		double opacity		/* 透明度渐变至目标值 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取该动画的拷贝对象
 | 	// 获取该动画的拷贝对象
 | ||||||
| 	virtual ActionOpacityTo * clone() const override; | 	virtual OpacityTo * clone() const override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动画
 | 	// 初始化动画
 | ||||||
| 	virtual void _init() override; | 	virtual void _init() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	double _nEndVal; | 	double _endVal; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 淡入动画
 | // 淡入动画
 | ||||||
| class ActionFadeIn : | class FadeIn : | ||||||
| 	public ActionOpacityTo | 	public OpacityTo | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建淡入动画
 | 	// 创建淡入动画
 | ||||||
| 	ActionFadeIn( | 	FadeIn( | ||||||
| 		double duration		/* 动画持续时长 */ | 		double duration		/* 动画持续时长 */ | ||||||
| 	)  | 	) | ||||||
| 		: ActionOpacityTo(duration, 1)  | 	: OpacityTo(duration, 1)  | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 淡出动画
 | // 淡出动画
 | ||||||
| class ActionFadeOut : | class FadeOut : | ||||||
| 	public ActionOpacityTo | 	public OpacityTo | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建淡出动画
 | 	// 创建淡出动画
 | ||||||
| 	ActionFadeOut( | 	FadeOut( | ||||||
| 		double duration		/* 动画持续时长 */ | 		double duration		/* 动画持续时长 */ | ||||||
| 	)  | 	) | ||||||
| 		: ActionOpacityTo(duration, 0)  | 	: OpacityTo(duration, 0)  | ||||||
| 	{ | 	{ | ||||||
| 	} | 	} | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 相对旋转动作
 | // 相对旋转动作
 | ||||||
| class ActionRotateBy : | class RotateBy : | ||||||
| 	public ActionGradual | 	public ActionGradual | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建相对旋转动画
 | 	// 创建相对旋转动画
 | ||||||
| 	ActionRotateBy( | 	RotateBy( | ||||||
| 		double duration,	/* 动画持续时长 */ | 		double duration,	/* 动画持续时长 */ | ||||||
| 		double rotation		/* 旋转角度变化值 */ | 		double rotation		/* 旋转角度变化值 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取该动画的拷贝对象
 | 	// 获取该动画的拷贝对象
 | ||||||
| 	virtual ActionRotateBy * clone() const override; | 	virtual RotateBy * clone() const override; | ||||||
| 
 | 
 | ||||||
| 	// 获取该动画的倒转
 | 	// 获取该动画的倒转
 | ||||||
| 	virtual ActionRotateBy * reverse() const override; | 	virtual RotateBy * reverse() const override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动画
 | 	// 初始化动画
 | ||||||
|  | @ -485,61 +342,80 @@ protected: | ||||||
| 	virtual void _update() override; | 	virtual void _update() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	double _nBeginVal; | 	double _startVal; | ||||||
| 	double _nVariation; | 	double _deltaVal; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 旋转动作
 | // 旋转动作
 | ||||||
| class ActionRotateTo : | class RotateTo : | ||||||
| 	public ActionRotateBy | 	public RotateBy | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建旋转动画
 | 	// 创建旋转动画
 | ||||||
| 	ActionRotateTo( | 	RotateTo( | ||||||
| 		double duration,	/* 动画持续时长 */ | 		double duration,	/* 动画持续时长 */ | ||||||
| 		double rotation		/* 旋转角度至目标值 */ | 		double rotation		/* 旋转角度至目标值 */ | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取该动画的拷贝对象
 | 	// 获取该动画的拷贝对象
 | ||||||
| 	virtual ActionRotateTo * clone() const override; | 	virtual RotateTo * clone() const override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动画
 | 	// 初始化动画
 | ||||||
| 	virtual void _init() override; | 	virtual void _init() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	double _nEndVal; | 	double _endVal; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 组合动作
 | // 延时动作
 | ||||||
| class ActionTwo : | class Delay : | ||||||
| 	public ActionBase | 	public Action | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建两个动作的连续动作
 | 	// 创建延时动作
 | ||||||
| 	ActionTwo( | 	Delay( | ||||||
| 		ActionBase * pActionFirst,		/* 第一个动作 */ | 		double duration	/* 延迟时长(秒) */ | ||||||
| 		ActionBase * pActionSecond,		/* 第二个动作 */ |  | ||||||
| 		bool bAtSameTime = false		/* 同时开始 */ |  | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	virtual ~ActionTwo(); | 	// 获取该动作的拷贝对象
 | ||||||
|  | 	virtual Delay * clone() const override; | ||||||
|  | 
 | ||||||
|  | protected: | ||||||
|  | 	// 初始化动作
 | ||||||
|  | 	virtual void _init() override; | ||||||
|  | 
 | ||||||
|  | 	// 执行动作
 | ||||||
|  | 	virtual void _update() override; | ||||||
|  | 
 | ||||||
|  | protected: | ||||||
|  | 	double _delay; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | // 循环动作
 | ||||||
|  | class Loop : | ||||||
|  | 	public Action | ||||||
|  | { | ||||||
|  | public: | ||||||
|  | 	// 创建循环动作
 | ||||||
|  | 	Loop( | ||||||
|  | 		Action * action,	/* 执行循环的动作 */ | ||||||
|  | 		int times = -1		/* 循环次数 */ | ||||||
|  | 	); | ||||||
|  | 
 | ||||||
|  | 	virtual ~Loop(); | ||||||
| 
 | 
 | ||||||
| 	// 获取该动作的拷贝对象
 | 	// 获取该动作的拷贝对象
 | ||||||
| 	virtual ActionTwo * clone() const override; | 	virtual Loop * clone() const override; | ||||||
| 
 |  | ||||||
| 	// 获取该动作的倒转
 |  | ||||||
| 	virtual ActionTwo * reverse( |  | ||||||
| 		bool actionReverse = true	/* 子动作是否倒转 */ |  | ||||||
| 	) const; |  | ||||||
| 
 | 
 | ||||||
| 	// 重置动作
 | 	// 重置动作
 | ||||||
| 	virtual void reset() override; | 	virtual void reset() override; | ||||||
| 
 | 
 | ||||||
| 	// 销毁对象
 | 	// 销毁对象
 | ||||||
| 	virtual void destroy() override; | 	virtual void onDestroy() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动作
 | 	// 初始化动作
 | ||||||
|  | @ -552,68 +428,91 @@ protected: | ||||||
| 	virtual void _resetTime() override; | 	virtual void _resetTime() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	ActionBase*	_pFirstAction; | 	Action * _action; | ||||||
| 	ActionBase*	_pSecondAction; | 	int _times; | ||||||
| 	bool	_bAtSameTime; | 	int _totalTimes; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | // 回调动作
 | ||||||
|  | class CallFunc : | ||||||
|  | 	public Action | ||||||
|  | { | ||||||
|  | public: | ||||||
|  | 	// 创建执行函数对象的动作
 | ||||||
|  | 	CallFunc( | ||||||
|  | 		const Function& func /* 函数对象 */ | ||||||
|  | 	); | ||||||
|  | 
 | ||||||
|  | 	// 获取该动作的拷贝对象
 | ||||||
|  | 	virtual CallFunc * clone() const override; | ||||||
|  | 
 | ||||||
|  | protected: | ||||||
|  | 	// 初始化动作
 | ||||||
|  | 	virtual void _init() override; | ||||||
|  | 
 | ||||||
|  | 	// 执行动作
 | ||||||
|  | 	virtual void _update() override; | ||||||
|  | 
 | ||||||
|  | protected: | ||||||
|  | 	Function _func; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 顺序动作
 | // 顺序动作
 | ||||||
| class ActionSequence : | class Sequence : | ||||||
| 	public ActionBase | 	public Action | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建顺序动作
 | 	// 创建顺序动作
 | ||||||
| 	ActionSequence(); | 	Sequence(); | ||||||
| 
 | 
 | ||||||
| #ifdef HIGHER_THAN_VS2012 | #ifdef HIGHER_THAN_VS2012 | ||||||
| 	// 创建顺序动作
 | 	// 创建顺序动作
 | ||||||
| 	ActionSequence( | 	Sequence( | ||||||
| 		const std::initializer_list<ActionBase*>& vActions	/* 动作列表 */ | 		const std::initializer_list<Action*>& vActions	/* 动作列表 */ | ||||||
| 	); | 	); | ||||||
| #else | #else | ||||||
| 	// 创建顺序动作
 | 	// 创建顺序动作
 | ||||||
| 	ActionSequence( | 	Sequence( | ||||||
| 		int number,				/* 动作数量 */ | 		int number,				/* 动作数量 */ | ||||||
| 		ActionBase * action,	/* 第一个动作 */ | 		Action * action,	/* 第一个动作 */ | ||||||
| 		... | 		... | ||||||
| 	); | 	); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 	virtual ~ActionSequence(); | 	virtual ~Sequence(); | ||||||
| 
 | 
 | ||||||
| 	// 在结尾添加动作
 | 	// 在结尾添加动作
 | ||||||
| 	void add( | 	void add( | ||||||
| 		ActionBase * action | 		Action * action | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| #ifdef HIGHER_THAN_VS2012 | #ifdef HIGHER_THAN_VS2012 | ||||||
| 	// 在结尾添加多个动作
 | 	// 在结尾添加多个动作
 | ||||||
| 	void add( | 	void add( | ||||||
| 		const std::initializer_list<ActionBase*>& vActions	/* 动作列表 */ | 		const std::initializer_list<Action*>& vActions	/* 动作列表 */ | ||||||
| 	); | 	); | ||||||
| #else | #else | ||||||
| 	// 在结尾添加多个动作
 | 	// 在结尾添加多个动作
 | ||||||
| 	void add( | 	void add( | ||||||
| 		int number,			/* 动作数量 */ | 		int number,			/* 动作数量 */ | ||||||
| 		ActionBase * action,	/* 第一个动作 */ | 		Action * action,	/* 第一个动作 */ | ||||||
| 		... | 		... | ||||||
| 	); | 	); | ||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| 	// 获取该动作的拷贝对象
 | 	// 获取该动作的拷贝对象
 | ||||||
| 	virtual ActionSequence * clone() const override; | 	virtual Sequence * clone() const override; | ||||||
| 
 | 
 | ||||||
| 	// 获取该动作的倒转
 | 	// 获取该动作的倒转
 | ||||||
| 	virtual ActionSequence * reverse( | 	virtual Sequence * reverse() const; | ||||||
| 		bool actionReverse = true	/* 子动作是否倒转 */ |  | ||||||
| 	) const; |  | ||||||
| 
 | 
 | ||||||
| 	// 重置动作
 | 	// 重置动作
 | ||||||
| 	virtual void reset() override; | 	virtual void reset() override; | ||||||
| 
 | 
 | ||||||
| 	// 销毁对象
 | 	// 销毁对象
 | ||||||
| 	virtual void destroy() override; | 	virtual void onDestroy() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动作
 | 	// 初始化动作
 | ||||||
|  | @ -626,57 +525,65 @@ protected: | ||||||
| 	virtual void _resetTime() override; | 	virtual void _resetTime() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	UINT _nActionIndex; | 	UINT _currIndex; | ||||||
| 	std::vector<ActionBase*> _vActions; | 	std::vector<Action*> _actions; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 延时动作
 | // 同步动作
 | ||||||
| class ActionDelay : | class Spawn : | ||||||
| 	public ActionBase | 	public Action | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建延时动作
 | 	// 创建同步动作
 | ||||||
| 	ActionDelay( | 	Spawn(); | ||||||
| 		double duration	/* 延迟时长(秒) */ | 
 | ||||||
|  | #ifdef HIGHER_THAN_VS2012 | ||||||
|  | 	// 创建同步动作
 | ||||||
|  | 	Spawn( | ||||||
|  | 		const std::initializer_list<Action*>& vActions	/* 动作列表 */ | ||||||
|  | 	); | ||||||
|  | #else | ||||||
|  | 	// 创建同步动作
 | ||||||
|  | 	Spawn( | ||||||
|  | 		int number,			/* 动作数量 */ | ||||||
|  | 		Action * action,	/* 第一个动作 */ | ||||||
|  | 		... | ||||||
|  | 	); | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | 	virtual ~Spawn(); | ||||||
|  | 
 | ||||||
|  | 	// 在结尾添加动作
 | ||||||
|  | 	void add( | ||||||
|  | 		Action * action | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取该动作的拷贝对象
 | #ifdef HIGHER_THAN_VS2012 | ||||||
| 	virtual ActionDelay * clone() const override; | 	// 在结尾添加多个动作
 | ||||||
| 
 | 	void add( | ||||||
| protected: | 		const std::initializer_list<Action*>& vActions	/* 动作列表 */ | ||||||
| 	// 初始化动作
 |  | ||||||
| 	virtual void _init() override; |  | ||||||
| 
 |  | ||||||
| 	// 执行动作
 |  | ||||||
| 	virtual void _update() override; |  | ||||||
| 
 |  | ||||||
| protected: |  | ||||||
| 	double _fDelayTime; |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| // 循环动作
 |  | ||||||
| class ActionLoop : |  | ||||||
| 	public ActionBase |  | ||||||
| { |  | ||||||
| public: |  | ||||||
| 	// 创建循环动作
 |  | ||||||
| 	ActionLoop( |  | ||||||
| 		ActionBase * action,	/* 执行循环的动作 */ |  | ||||||
| 		int times = -1		/* 循环次数 */ |  | ||||||
| 	); | 	); | ||||||
| 
 | #else | ||||||
| 	virtual ~ActionLoop(); | 	// 在结尾添加多个动作
 | ||||||
|  | 	void add( | ||||||
|  | 		int number,			/* 动作数量 */ | ||||||
|  | 		Action * action,	/* 第一个动作 */ | ||||||
|  | 		... | ||||||
|  | 	); | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| 	// 获取该动作的拷贝对象
 | 	// 获取该动作的拷贝对象
 | ||||||
| 	virtual ActionLoop * clone() const override; | 	virtual Spawn * clone() const override; | ||||||
|  | 
 | ||||||
|  | 	// 获取该动作的倒转
 | ||||||
|  | 	virtual Spawn * reverse() const; | ||||||
| 
 | 
 | ||||||
| 	// 重置动作
 | 	// 重置动作
 | ||||||
| 	virtual void reset() override; | 	virtual void reset() override; | ||||||
| 
 | 
 | ||||||
| 	// 销毁对象
 | 	// 销毁对象
 | ||||||
| 	virtual void destroy() override; | 	virtual void onDestroy() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动作
 | 	// 初始化动作
 | ||||||
|  | @ -689,15 +596,13 @@ protected: | ||||||
| 	virtual void _resetTime() override; | 	virtual void _resetTime() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	ActionBase * _pAction; | 	std::vector<Action*> _actions; | ||||||
| 	int _nTimes; |  | ||||||
| 	int _nTotalTimes; |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // 帧动画
 | // 帧动画
 | ||||||
| class Animation : | class Animation : | ||||||
| 	public ActionBase | 	public Action | ||||||
| { | { | ||||||
| public: | public: | ||||||
| 	// 创建帧动画
 | 	// 创建帧动画
 | ||||||
|  | @ -772,7 +677,7 @@ public: | ||||||
| 	virtual void reset() override; | 	virtual void reset() override; | ||||||
| 
 | 
 | ||||||
| 	// 销毁对象
 | 	// 销毁对象
 | ||||||
| 	virtual void destroy() override; | 	virtual void onDestroy() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化动作
 | 	// 初始化动作
 | ||||||
|  | @ -782,34 +687,9 @@ protected: | ||||||
| 	virtual void _update() override; | 	virtual void _update() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	double	_fInterval; | 	double	_interval; | ||||||
| 	UINT	_nFrameIndex; | 	UINT	_frameIndex; | ||||||
| 	std::vector<Image*> _vFrames; | 	std::vector<Image*> _frames; | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| // 回调动作
 |  | ||||||
| class ActionFunc : |  | ||||||
| 	public ActionBase |  | ||||||
| { |  | ||||||
| public: |  | ||||||
| 	// 创建执行函数对象的动作
 |  | ||||||
| 	ActionFunc( |  | ||||||
| 		const Function& func /* 函数对象 */ |  | ||||||
| 	); |  | ||||||
| 
 |  | ||||||
| 	// 获取该动作的拷贝对象
 |  | ||||||
| 	virtual ActionFunc * clone() const override; |  | ||||||
| 
 |  | ||||||
| protected: |  | ||||||
| 	// 初始化动作
 |  | ||||||
| 	virtual void _init() override; |  | ||||||
| 
 |  | ||||||
| 	// 执行动作
 |  | ||||||
| 	virtual void _update() override; |  | ||||||
| 
 |  | ||||||
| protected: |  | ||||||
| 	Function _Callback; |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -590,7 +590,7 @@ public: | ||||||
| 	int getRefCount() const; | 	int getRefCount() const; | ||||||
| 
 | 
 | ||||||
| 	// 销毁对象
 | 	// 销毁对象
 | ||||||
| 	virtual void destroy() {} | 	virtual void onDestroy() {} | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
| 	int _nRefCount; | 	int _nRefCount; | ||||||
|  | @ -789,7 +789,7 @@ public: | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 销毁对象
 | 	// 销毁对象
 | ||||||
| 	virtual void destroy() override; | 	virtual void onDestroy() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 渲染场景画面
 | 	// 渲染场景画面
 | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ class Input; | ||||||
| class Renderer; | class Renderer; | ||||||
| class Node; | class Node; | ||||||
| class Timer; | class Timer; | ||||||
| class ActionBase; | class Action; | ||||||
| class Music; | class Music; | ||||||
| class Collider; | class Collider; | ||||||
| class TransitionBase; | class TransitionBase; | ||||||
|  | @ -90,12 +90,12 @@ class ActionManager | ||||||
| { | { | ||||||
| 	friend Game; | 	friend Game; | ||||||
| 	friend Node; | 	friend Node; | ||||||
| 	friend ActionBase; | 	friend Action; | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
| 	// 执行动作
 | 	// 执行动作
 | ||||||
| 	static void start( | 	static void start( | ||||||
| 		ActionBase * action, | 		Action * action, | ||||||
| 		Node * target, | 		Node * target, | ||||||
| 		bool paused | 		bool paused | ||||||
| 	); | 	); | ||||||
|  | @ -125,12 +125,12 @@ public: | ||||||
| 	static void stopAll(); | 	static void stopAll(); | ||||||
| 
 | 
 | ||||||
| 	// 获取所有名称相同的动作
 | 	// 获取所有名称相同的动作
 | ||||||
| 	static std::vector<ActionBase *> get( | 	static std::vector<Action *> get( | ||||||
| 		const String& strActionName | 		const String& strActionName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取所有动作
 | 	// 获取所有动作
 | ||||||
| 	static std::vector<ActionBase*> getAll(); | 	static std::vector<Action*> getAll(); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
| 	// 更新动画状态
 | 	// 更新动画状态
 | ||||||
|  | @ -138,12 +138,12 @@ private: | ||||||
| 
 | 
 | ||||||
| 	// 添加动作
 | 	// 添加动作
 | ||||||
| 	static void __add( | 	static void __add( | ||||||
| 		ActionBase * action | 		Action * action | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 删除动作
 | 	// 删除动作
 | ||||||
| 	static void __remove( | 	static void __remove( | ||||||
| 		ActionBase * action | 		Action * action | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 继续绑定在节点上的所有动作
 | 	// 继续绑定在节点上的所有动作
 | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ namespace e2d | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class ActionBase; | class Action; | ||||||
| class TransitionBase; | class TransitionBase; | ||||||
| class Collider; | class Collider; | ||||||
| class ColliderManager; | class ColliderManager; | ||||||
|  | @ -366,7 +366,7 @@ public: | ||||||
| 
 | 
 | ||||||
| 	// 执行动画
 | 	// 执行动画
 | ||||||
| 	virtual void runAction( | 	virtual void runAction( | ||||||
| 		ActionBase * action | 		Action * action | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 继续动画
 | 	// 继续动画
 | ||||||
|  | @ -385,12 +385,12 @@ public: | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取名称相同的动画
 | 	// 获取名称相同的动画
 | ||||||
| 	virtual ActionBase * getAction( | 	virtual Action * getAction( | ||||||
| 		const String& strActionName | 		const String& strActionName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 获取所有名称相同的动画
 | 	// 获取所有名称相同的动画
 | ||||||
| 	virtual std::vector<ActionBase*> getActions( | 	virtual std::vector<Action*> getActions( | ||||||
| 		const String& strActionName | 		const String& strActionName | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
|  | @ -415,7 +415,7 @@ public: | ||||||
| 	); | 	); | ||||||
| 
 | 
 | ||||||
| 	// 销毁对象
 | 	// 销毁对象
 | ||||||
| 	virtual void destroy() override; | 	virtual void onDestroy() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 更新节点
 | 	// 更新节点
 | ||||||
|  | @ -442,7 +442,7 @@ protected: | ||||||
| 	void _updateOpacity(); | 	void _updateOpacity(); | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	String		_sName; | 	String		_name; | ||||||
| 	unsigned	_nHashName; | 	unsigned	_nHashName; | ||||||
| 	float		_fPosX; | 	float		_fPosX; | ||||||
| 	float		_fPosY; | 	float		_fPosY; | ||||||
|  | @ -548,7 +548,7 @@ public: | ||||||
| 	virtual void onRender() override; | 	virtual void onRender() override; | ||||||
| 
 | 
 | ||||||
| 	// 销毁对象
 | 	// 销毁对象
 | ||||||
| 	virtual void destroy() override; | 	virtual void onDestroy() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	Image * _pImage; | 	Image * _pImage; | ||||||
|  | @ -836,7 +836,7 @@ protected: | ||||||
| 	bool		_bEnable; | 	bool		_bEnable; | ||||||
| 	bool		_bIsSelected; | 	bool		_bIsSelected; | ||||||
| 	ButtonState	_eBtnState; | 	ButtonState	_eBtnState; | ||||||
| 	Function	_Callback; | 	Function	_func; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -54,7 +54,7 @@ public: | ||||||
| 	bool isDone(); | 	bool isDone(); | ||||||
| 
 | 
 | ||||||
| 	// 销毁对象
 | 	// 销毁对象
 | ||||||
| 	virtual void destroy() override; | 	virtual void onDestroy() override; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| 	// 初始化场景动画
 | 	// 初始化场景动画
 | ||||||
|  | @ -81,8 +81,8 @@ protected: | ||||||
| protected: | protected: | ||||||
| 	bool _bEnd; | 	bool _bEnd; | ||||||
| 	double _fLast; | 	double _fLast; | ||||||
| 	double _fDuration; | 	double _duration; | ||||||
| 	double _fRateOfProgress; | 	double _delta; | ||||||
| 	Size _WindowSize; | 	Size _WindowSize; | ||||||
| 	Scene * _pPrevScene; | 	Scene * _pPrevScene; | ||||||
| 	Scene * _pNextScene; | 	Scene * _pNextScene; | ||||||
|  |  | ||||||
|  | @ -197,22 +197,21 @@ | ||||||
|   </ItemDefinitionGroup> |   </ItemDefinitionGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClCompile Include="..\..\core\Action\Action.cpp" /> |     <ClCompile Include="..\..\core\Action\Action.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionBase.cpp" /> |     <ClCompile Include="..\..\core\Action\CallFunc.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionFunc.cpp" /> |     <ClCompile Include="..\..\core\Action\Delay.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionDelay.cpp" /> |     <ClCompile Include="..\..\core\Action\MoveBy.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionMoveBy.cpp" /> |  | ||||||
|     <ClCompile Include="..\..\core\Action\Animation.cpp" /> |     <ClCompile Include="..\..\core\Action\Animation.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionMoveTo.cpp" /> |     <ClCompile Include="..\..\core\Action\MoveTo.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionLoop.cpp" /> |     <ClCompile Include="..\..\core\Action\Loop.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionOpacityBy.cpp" /> |     <ClCompile Include="..\..\core\Action\OpacityBy.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionOpacityTo.cpp" /> |     <ClCompile Include="..\..\core\Action\OpacityTo.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionRotateBy.cpp" /> |     <ClCompile Include="..\..\core\Action\RotateBy.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionRotateTo.cpp" /> |     <ClCompile Include="..\..\core\Action\RotateTo.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionScaleBy.cpp" /> |     <ClCompile Include="..\..\core\Action\ScaleBy.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionScaleTo.cpp" /> |     <ClCompile Include="..\..\core\Action\ScaleTo.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionSequence.cpp" /> |     <ClCompile Include="..\..\core\Action\Sequence.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionTwo.cpp" /> |  | ||||||
|     <ClCompile Include="..\..\core\Action\ActionGradual.cpp" /> |     <ClCompile Include="..\..\core\Action\ActionGradual.cpp" /> | ||||||
|  |     <ClCompile Include="..\..\core\Action\Spawn.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Base\Game.cpp" /> |     <ClCompile Include="..\..\core\Base\Game.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Base\Input.cpp" /> |     <ClCompile Include="..\..\core\Base\Input.cpp" /> | ||||||
|     <ClCompile Include="..\..\core\Base\Renderer.cpp" /> |     <ClCompile Include="..\..\core\Base\Renderer.cpp" /> | ||||||
|  |  | ||||||
|  | @ -36,45 +36,9 @@ | ||||||
|     <ClCompile Include="..\..\core\Base\Input.cpp"> |     <ClCompile Include="..\..\core\Base\Input.cpp"> | ||||||
|       <Filter>Base</Filter> |       <Filter>Base</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionDelay.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\ActionGradual.cpp"> |     <ClCompile Include="..\..\core\Action\ActionGradual.cpp"> | ||||||
|       <Filter>Action</Filter> |       <Filter>Action</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionLoop.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\ActionMoveBy.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\ActionMoveTo.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\ActionOpacityBy.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\ActionOpacityTo.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\ActionRotateBy.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\ActionRotateTo.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\ActionScaleBy.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\ActionScaleTo.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\ActionSequence.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\ActionTwo.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\Animation.cpp"> |     <ClCompile Include="..\..\core\Action\Animation.cpp"> | ||||||
|       <Filter>Action</Filter> |       <Filter>Action</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|  | @ -162,9 +126,6 @@ | ||||||
|     <ClCompile Include="..\..\core\Manager\InputManager.cpp"> |     <ClCompile Include="..\..\core\Manager\InputManager.cpp"> | ||||||
|       <Filter>Manager</Filter> |       <Filter>Manager</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionFunc.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Collider\Collider.cpp"> |     <ClCompile Include="..\..\core\Collider\Collider.cpp"> | ||||||
|       <Filter>Collider</Filter> |       <Filter>Collider</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|  | @ -207,18 +168,54 @@ | ||||||
|     <ClCompile Include="..\..\core\Common\Function.cpp"> |     <ClCompile Include="..\..\core\Common\Function.cpp"> | ||||||
|       <Filter>Common</Filter> |       <Filter>Common</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|     <ClCompile Include="..\..\core\Action\ActionBase.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Action\Action.cpp"> |  | ||||||
|       <Filter>Action</Filter> |  | ||||||
|     </ClCompile> |  | ||||||
|     <ClCompile Include="..\..\core\Transition\TransitionBase.cpp"> |     <ClCompile Include="..\..\core\Transition\TransitionBase.cpp"> | ||||||
|       <Filter>Transition</Filter> |       <Filter>Transition</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|     <ClCompile Include="..\..\core\Transition\Transition.cpp"> |     <ClCompile Include="..\..\core\Transition\Transition.cpp"> | ||||||
|       <Filter>Transition</Filter> |       <Filter>Transition</Filter> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\Action.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\Sequence.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\ScaleTo.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\ScaleBy.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\RotateTo.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\RotateBy.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\OpacityTo.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\OpacityBy.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\MoveTo.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\MoveBy.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\Loop.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\CallFunc.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\Delay.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|  |     <ClCompile Include="..\..\core\Action\Spawn.cpp"> | ||||||
|  |       <Filter>Action</Filter> | ||||||
|  |     </ClCompile> | ||||||
|   </ItemGroup> |   </ItemGroup> | ||||||
|   <ItemGroup> |   <ItemGroup> | ||||||
|     <ClInclude Include="..\..\core\easy2d.h" /> |     <ClInclude Include="..\..\core\easy2d.h" /> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue