新增Animate类;细节调整
This commit is contained in:
parent
4a62b2a5bf
commit
f66a56e028
|
|
@ -21,7 +21,7 @@ void e2d::ActionGradual::_update()
|
||||||
this->stop();
|
this->stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 计算动画进度
|
// 计算动作进度
|
||||||
_delta = min((Time::getTotalTime() - _last) / _duration, 1);
|
_delta = min((Time::getTotalTime() - _last) / _duration, 1);
|
||||||
// 判断动作是否结束
|
// 判断动作是否结束
|
||||||
if (_delta >= 1)
|
if (_delta >= 1)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,114 @@
|
||||||
|
#include "..\e2daction.h"
|
||||||
|
|
||||||
|
e2d::Animate::Animate()
|
||||||
|
: _frameIndex(0)
|
||||||
|
, _animation(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Animate::Animate(Animation * animation)
|
||||||
|
: _frameIndex(0)
|
||||||
|
, _animation(nullptr)
|
||||||
|
{
|
||||||
|
this->setAnimation(animation);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Animate::~Animate()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Animation * e2d::Animate::getAnimation() const
|
||||||
|
{
|
||||||
|
return _animation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Animate::setAnimation(Animation * animation)
|
||||||
|
{
|
||||||
|
if (animation && animation != _animation)
|
||||||
|
{
|
||||||
|
SafeRelease(&_animation);
|
||||||
|
_animation = animation;
|
||||||
|
_animation->retain();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Animate::_init()
|
||||||
|
{
|
||||||
|
Action::_init();
|
||||||
|
|
||||||
|
auto target = dynamic_cast<Sprite*>(_target);
|
||||||
|
if (target && _animation)
|
||||||
|
{
|
||||||
|
target->open(_animation->getFrames()[_frameIndex]);
|
||||||
|
++_frameIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Animate::_update()
|
||||||
|
{
|
||||||
|
Action::_update();
|
||||||
|
|
||||||
|
if (!_animation)
|
||||||
|
{
|
||||||
|
this->stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((Time::getTotalTime() - _last) >= _animation->getInterval())
|
||||||
|
{
|
||||||
|
auto& frames = _animation->getFrames();
|
||||||
|
auto target = dynamic_cast<Sprite*>(_target);
|
||||||
|
|
||||||
|
if (target)
|
||||||
|
{
|
||||||
|
target->open(frames[_frameIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
_last += _animation->getInterval();
|
||||||
|
_frameIndex++;
|
||||||
|
|
||||||
|
if (_frameIndex == frames.size())
|
||||||
|
{
|
||||||
|
this->stop();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Animate::reset()
|
||||||
|
{
|
||||||
|
Action::reset();
|
||||||
|
_frameIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Animate::onDestroy()
|
||||||
|
{
|
||||||
|
Action::onDestroy();
|
||||||
|
SafeRelease(&_animation);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Animate * e2d::Animate::clone() const
|
||||||
|
{
|
||||||
|
return new (std::nothrow) Animate(_animation);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Animate * e2d::Animate::reverse() const
|
||||||
|
{
|
||||||
|
auto& oldFrames = _animation->getFrames();
|
||||||
|
std::vector<Image*> frames(oldFrames.size());
|
||||||
|
|
||||||
|
if (!oldFrames.empty())
|
||||||
|
{
|
||||||
|
for (auto iter = oldFrames.crbegin(), iterCrend = oldFrames.crend(); iter != iterCrend; ++iter)
|
||||||
|
{
|
||||||
|
Image* frame = *iter;
|
||||||
|
if (frame)
|
||||||
|
{
|
||||||
|
frames.push_back(frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto animation = new (std::nothrow) Animation(_animation->getInterval(), frames);
|
||||||
|
return new (std::nothrow) Animate(animation);
|
||||||
|
}
|
||||||
|
|
@ -1,168 +0,0 @@
|
||||||
#include "..\e2daction.h"
|
|
||||||
|
|
||||||
e2d::Animation::Animation()
|
|
||||||
: _frameIndex(0)
|
|
||||||
, _interval(1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
e2d::Animation::Animation(double interval)
|
|
||||||
: _frameIndex(0)
|
|
||||||
, _interval(interval)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
|
||||||
|
|
||||||
e2d::Animation::Animation(const std::initializer_list<Image*>& vImages)
|
|
||||||
: _frameIndex(0)
|
|
||||||
, _interval(1)
|
|
||||||
{
|
|
||||||
this->add(vImages);
|
|
||||||
}
|
|
||||||
|
|
||||||
e2d::Animation::Animation(double interval, const std::initializer_list<Image*>& vImages)
|
|
||||||
: _frameIndex(0)
|
|
||||||
, _interval(interval)
|
|
||||||
{
|
|
||||||
this->add(vImages);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
e2d::Animation::Animation(int number, Image * frame, ...)
|
|
||||||
: _frameIndex(0)
|
|
||||||
, _interval(1)
|
|
||||||
{
|
|
||||||
Image ** ppImage = &frame;
|
|
||||||
|
|
||||||
while (number > 0)
|
|
||||||
{
|
|
||||||
WARN_IF((*ppImage) == nullptr, "Animation NULL pointer exception!");
|
|
||||||
this->add(*ppImage);
|
|
||||||
ppImage++;
|
|
||||||
number--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
e2d::Animation::Animation(double interval, int number, Image * frame, ...)
|
|
||||||
: _frameIndex(0)
|
|
||||||
, _interval(interval)
|
|
||||||
{
|
|
||||||
Image ** ppImage = &frame;
|
|
||||||
|
|
||||||
while (number > 0)
|
|
||||||
{
|
|
||||||
WARN_IF((*ppImage) == nullptr, "Animation NULL pointer exception!");
|
|
||||||
this->add(*ppImage);
|
|
||||||
ppImage++;
|
|
||||||
number--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
e2d::Animation::~Animation()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::Animation::setInterval(double interval)
|
|
||||||
{
|
|
||||||
_interval = max(interval, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::Animation::_init()
|
|
||||||
{
|
|
||||||
Action::_init();
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::Animation::_update()
|
|
||||||
{
|
|
||||||
Action::_update();
|
|
||||||
|
|
||||||
if (_target == nullptr)
|
|
||||||
{
|
|
||||||
this->stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 判断时间间隔是否足够
|
|
||||||
while ((Time::getTotalTime() - _last) >= _interval)
|
|
||||||
{
|
|
||||||
// 重新记录时间
|
|
||||||
_last += _interval;
|
|
||||||
// 加载关键帧
|
|
||||||
static_cast<Sprite*>(_target)->open(_frames[_frameIndex]);
|
|
||||||
_frameIndex++;
|
|
||||||
// 判断动作是否结束
|
|
||||||
if (_frameIndex == _frames.size())
|
|
||||||
{
|
|
||||||
this->stop();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::Animation::reset()
|
|
||||||
{
|
|
||||||
Action::reset();
|
|
||||||
_frameIndex = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::Animation::onDestroy()
|
|
||||||
{
|
|
||||||
Action::onDestroy();
|
|
||||||
for (auto frame : _frames)
|
|
||||||
{
|
|
||||||
SafeRelease(&frame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void e2d::Animation::add(Image * frame)
|
|
||||||
{
|
|
||||||
if (frame)
|
|
||||||
{
|
|
||||||
_frames.push_back(frame);
|
|
||||||
frame->retain();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
|
||||||
void e2d::Animation::add(const std::initializer_list<Image*>& vImages)
|
|
||||||
{
|
|
||||||
for (const auto &image : vImages)
|
|
||||||
{
|
|
||||||
this->add(image);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
void e2d::Animation::add(int number, Image * frame, ...)
|
|
||||||
{
|
|
||||||
Image ** ppImage = &frame;
|
|
||||||
|
|
||||||
while (number > 0)
|
|
||||||
{
|
|
||||||
WARN_IF((*ppImage) == nullptr, "Animation NULL pointer exception!");
|
|
||||||
this->add(*ppImage);
|
|
||||||
ppImage++;
|
|
||||||
number--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
e2d::Animation * e2d::Animation::clone() const
|
|
||||||
{
|
|
||||||
auto a = new Animation(_interval);
|
|
||||||
for (auto frame : _frames)
|
|
||||||
{
|
|
||||||
a->add(frame);
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
e2d::Animation * e2d::Animation::reverse() const
|
|
||||||
{
|
|
||||||
auto a = this->clone();
|
|
||||||
a->_frames.reserve(_frames.size());
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
@ -10,6 +10,7 @@ e2d::MoveBy::MoveBy(double duration, Vector vector) :
|
||||||
void e2d::MoveBy::_init()
|
void e2d::MoveBy::_init()
|
||||||
{
|
{
|
||||||
ActionGradual::_init();
|
ActionGradual::_init();
|
||||||
|
|
||||||
if (_target)
|
if (_target)
|
||||||
{
|
{
|
||||||
_startPos = _target->getPos();
|
_startPos = _target->getPos();
|
||||||
|
|
@ -20,14 +21,11 @@ void e2d::MoveBy::_update()
|
||||||
{
|
{
|
||||||
ActionGradual::_update();
|
ActionGradual::_update();
|
||||||
|
|
||||||
if (_target == nullptr)
|
if (_target)
|
||||||
{
|
{
|
||||||
this->stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_target->setPos(_startPos + _deltaPos * _delta);
|
_target->setPos(_startPos + _deltaPos * _delta);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
e2d::MoveBy * e2d::MoveBy::clone() const
|
e2d::MoveBy * e2d::MoveBy::clone() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ e2d::OpacityBy::OpacityBy(double duration, double opacity) :
|
||||||
void e2d::OpacityBy::_init()
|
void e2d::OpacityBy::_init()
|
||||||
{
|
{
|
||||||
ActionGradual::_init();
|
ActionGradual::_init();
|
||||||
|
|
||||||
if (_target)
|
if (_target)
|
||||||
{
|
{
|
||||||
_startVal = _target->getOpacity();
|
_startVal = _target->getOpacity();
|
||||||
|
|
@ -20,14 +21,11 @@ void e2d::OpacityBy::_update()
|
||||||
{
|
{
|
||||||
ActionGradual::_update();
|
ActionGradual::_update();
|
||||||
|
|
||||||
if (_target == nullptr)
|
if (_target)
|
||||||
{
|
{
|
||||||
this->stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_target->setOpacity(_startVal + _deltaVal * _delta);
|
_target->setOpacity(_startVal + _deltaVal * _delta);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
e2d::OpacityBy * e2d::OpacityBy::clone() const
|
e2d::OpacityBy * e2d::OpacityBy::clone() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ e2d::RotateBy::RotateBy(double duration, double rotation) :
|
||||||
void e2d::RotateBy::_init()
|
void e2d::RotateBy::_init()
|
||||||
{
|
{
|
||||||
ActionGradual::_init();
|
ActionGradual::_init();
|
||||||
|
|
||||||
if (_target)
|
if (_target)
|
||||||
{
|
{
|
||||||
_startVal = _target->getRotation();
|
_startVal = _target->getRotation();
|
||||||
|
|
@ -20,14 +21,11 @@ void e2d::RotateBy::_update()
|
||||||
{
|
{
|
||||||
ActionGradual::_update();
|
ActionGradual::_update();
|
||||||
|
|
||||||
if (_target == nullptr)
|
if (_target)
|
||||||
{
|
{
|
||||||
this->stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_target->setRotation(_startVal + _deltaVal * _delta);
|
_target->setRotation(_startVal + _deltaVal * _delta);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
e2d::RotateBy * e2d::RotateBy::clone() const
|
e2d::RotateBy * e2d::RotateBy::clone() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ e2d::ScaleBy::ScaleBy(double duration, double scaleX, double scaleY)
|
||||||
void e2d::ScaleBy::_init()
|
void e2d::ScaleBy::_init()
|
||||||
{
|
{
|
||||||
ActionGradual::_init();
|
ActionGradual::_init();
|
||||||
|
|
||||||
if (_target)
|
if (_target)
|
||||||
{
|
{
|
||||||
_startScaleX = _target->getScaleX();
|
_startScaleX = _target->getScaleX();
|
||||||
|
|
@ -29,14 +30,11 @@ void e2d::ScaleBy::_update()
|
||||||
{
|
{
|
||||||
ActionGradual::_update();
|
ActionGradual::_update();
|
||||||
|
|
||||||
if (_target == nullptr)
|
if (_target)
|
||||||
{
|
{
|
||||||
this->stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_target->setScale(_startScaleX + _deltaX * _delta, _startScaleY + _deltaY * _delta);
|
_target->setScale(_startScaleX + _deltaX * _delta, _startScaleY + _deltaY * _delta);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
e2d::ScaleBy * e2d::ScaleBy::clone() const
|
e2d::ScaleBy * e2d::ScaleBy::clone() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,25 +5,26 @@ e2d::Sequence::Sequence()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
e2d::Sequence::Sequence(int number, Action * action, ...) :
|
||||||
e2d::Sequence::Sequence(const std::initializer_list<Action*>& vActions)
|
|
||||||
: _currIndex(0)
|
|
||||||
{
|
|
||||||
this->add(vActions);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
e2d::Sequence::Sequence(int number, Action * action1, ...) :
|
|
||||||
_currIndex(0)
|
_currIndex(0)
|
||||||
{
|
{
|
||||||
Action ** ppAction = &action1;
|
va_list args;
|
||||||
|
va_start(args, action);
|
||||||
|
|
||||||
while (number > 0)
|
this->add(action);
|
||||||
|
for (int i = 1; i < number; i++)
|
||||||
{
|
{
|
||||||
WARN_IF((*ppAction) == nullptr, "Sequence NULL pointer exception!");
|
this->add(va_arg(args, Action*));
|
||||||
this->add(*ppAction);
|
|
||||||
ppAction++;
|
|
||||||
number--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
e2d::Sequence::Sequence(const std::initializer_list<Action*>& actions)
|
||||||
|
: _currIndex(0)
|
||||||
|
{
|
||||||
|
this->add(actions);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -103,25 +104,26 @@ void e2d::Sequence::add(Action * action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#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, ...)
|
void e2d::Sequence::add(int number, Action * action, ...)
|
||||||
{
|
{
|
||||||
Action ** ppAction = &action;
|
va_list args;
|
||||||
|
va_start(args, action);
|
||||||
|
|
||||||
while (number > 0)
|
this->add(action);
|
||||||
|
for (int i = 1; i < number; i++)
|
||||||
{
|
{
|
||||||
WARN_IF((*ppAction) == nullptr, "Sequence NULL pointer exception!");
|
this->add(va_arg(args, Action*));
|
||||||
this->add(*ppAction);
|
}
|
||||||
ppAction++;
|
|
||||||
number--;
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
void e2d::Sequence::add(const std::initializer_list<Action*>& actions)
|
||||||
|
{
|
||||||
|
for (const auto &action : actions)
|
||||||
|
{
|
||||||
|
this->add(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -4,24 +4,24 @@ e2d::Spawn::Spawn()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
e2d::Spawn::Spawn(int number, Action * action, ...)
|
||||||
e2d::Spawn::Spawn(const std::initializer_list<Action*>& vActions)
|
|
||||||
{
|
{
|
||||||
this->add(vActions);
|
va_list args;
|
||||||
}
|
va_start(args, action);
|
||||||
#else
|
|
||||||
e2d::Spawn::Spawn(int number, Action * action1, ...) :
|
|
||||||
_currIndex(0)
|
|
||||||
{
|
|
||||||
Action ** ppAction = &action1;
|
|
||||||
|
|
||||||
while (number > 0)
|
this->add(action);
|
||||||
|
for (int i = 1; i < number; i++)
|
||||||
{
|
{
|
||||||
WARN_IF((*ppAction) == nullptr, "Spawn NULL pointer exception!");
|
this->add(va_arg(args, Action*));
|
||||||
this->add(*ppAction);
|
|
||||||
ppAction++;
|
|
||||||
number--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
e2d::Spawn::Spawn(const std::initializer_list<Action*>& actions)
|
||||||
|
{
|
||||||
|
this->add(actions);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -101,25 +101,26 @@ void e2d::Spawn::add(Action * action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#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, ...)
|
void e2d::Spawn::add(int number, Action * action, ...)
|
||||||
{
|
{
|
||||||
Action ** ppAction = &action;
|
va_list args;
|
||||||
|
va_start(args, action);
|
||||||
|
|
||||||
while (number > 0)
|
this->add(action);
|
||||||
|
for (int i = 1; i < number; i++)
|
||||||
{
|
{
|
||||||
WARN_IF((*ppAction) == nullptr, "Spawn NULL pointer exception!");
|
this->add(va_arg(args, Action*));
|
||||||
this->add(*ppAction);
|
}
|
||||||
ppAction++;
|
|
||||||
number--;
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
void e2d::Spawn::add(const std::initializer_list<Action*>& actions)
|
||||||
|
{
|
||||||
|
for (const auto &action : actions)
|
||||||
|
{
|
||||||
|
this->add(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ void e2d::Game::resume()
|
||||||
s_bPaused = false;
|
s_bPaused = false;
|
||||||
// 刷新当前时间
|
// 刷新当前时间
|
||||||
Time::__updateLast();
|
Time::__updateLast();
|
||||||
// 重置动画和定时器
|
// 重置动作和定时器
|
||||||
ActionManager::__resetAll();
|
ActionManager::__resetAll();
|
||||||
Timer::__resetAll();
|
Timer::__resetAll();
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +177,7 @@ void e2d::Game::destroy()
|
||||||
// 删除监听器
|
// 删除监听器
|
||||||
InputManager::__uninit();
|
InputManager::__uninit();
|
||||||
ColliderManager::__uninit();
|
ColliderManager::__uninit();
|
||||||
// 删除动画
|
// 删除动作
|
||||||
ActionManager::__uninit();
|
ActionManager::__uninit();
|
||||||
// 删除所有对象
|
// 删除所有对象
|
||||||
ObjectManager::__clear();
|
ObjectManager::__clear();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,139 @@
|
||||||
|
#include "..\e2dcommon.h"
|
||||||
|
|
||||||
|
e2d::Animation::Animation()
|
||||||
|
: _interval(1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Animation::Animation(double interval)
|
||||||
|
: _interval(interval)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Animation::Animation(double interval, const std::vector<Image*>& frames)
|
||||||
|
: _interval(interval)
|
||||||
|
{
|
||||||
|
for (auto frame : frames)
|
||||||
|
{
|
||||||
|
this->add(frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Animation::Animation(int number, Image * frame, ...)
|
||||||
|
: _interval(1)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, frame);
|
||||||
|
|
||||||
|
this->add(frame);
|
||||||
|
for (int i = 1; i < number; i++)
|
||||||
|
{
|
||||||
|
this->add(va_arg(args, Image*));
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Animation::Animation(double interval, int number, Image * frame, ...)
|
||||||
|
: _interval(interval)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, frame);
|
||||||
|
|
||||||
|
this->add(frame);
|
||||||
|
for (int i = 1; i < number; i++)
|
||||||
|
{
|
||||||
|
this->add(va_arg(args, Image*));
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
|
||||||
|
e2d::Animation::Animation(const std::initializer_list<Image*>& frames)
|
||||||
|
: _interval(1)
|
||||||
|
{
|
||||||
|
this->add(frames);
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Animation::Animation(double interval, const std::initializer_list<Image*>& frames)
|
||||||
|
: _interval(interval)
|
||||||
|
{
|
||||||
|
this->add(frames);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
e2d::Animation::~Animation()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Animation::setInterval(double interval)
|
||||||
|
{
|
||||||
|
_interval = max(interval, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Animation::onDestroy()
|
||||||
|
{
|
||||||
|
for (auto frame : _frames)
|
||||||
|
{
|
||||||
|
SafeRelease(&frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Animation::add(Image * frame)
|
||||||
|
{
|
||||||
|
if (frame)
|
||||||
|
{
|
||||||
|
_frames.push_back(frame);
|
||||||
|
frame->retain();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void e2d::Animation::add(int number, Image * frame, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, frame);
|
||||||
|
|
||||||
|
this->add(frame);
|
||||||
|
--number;
|
||||||
|
|
||||||
|
while (number > 0)
|
||||||
|
{
|
||||||
|
this->add(va_arg(args, Image*));
|
||||||
|
--number;
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
void e2d::Animation::add(const std::initializer_list<Image*>& frames)
|
||||||
|
{
|
||||||
|
for (const auto &image : frames)
|
||||||
|
{
|
||||||
|
this->add(image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
double e2d::Animation::getInterval() const
|
||||||
|
{
|
||||||
|
return _interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<e2d::Image*>& e2d::Animation::getFrames() const
|
||||||
|
{
|
||||||
|
return _frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
e2d::Animation * e2d::Animation::clone() const
|
||||||
|
{
|
||||||
|
auto a = new Animation(_interval);
|
||||||
|
for (auto frame : _frames)
|
||||||
|
{
|
||||||
|
a->add(frame);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
@ -192,6 +192,7 @@ bool e2d::Image::preload(const String& fileName)
|
||||||
// (DXGI_FORMAT_B8G8R8A8_UNORM + D2D1_ALPHA_MODE_PREMULTIPLIED).
|
// (DXGI_FORMAT_B8G8R8A8_UNORM + D2D1_ALPHA_MODE_PREMULTIPLIED).
|
||||||
hr = Renderer::getIWICImagingFactory()->CreateFormatConverter(&pConverter);
|
hr = Renderer::getIWICImagingFactory()->CreateFormatConverter(&pConverter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
// 图片格式转换成 32bbpPBGRA
|
// 图片格式转换成 32bbpPBGRA
|
||||||
|
|
@ -204,6 +205,7 @@ bool e2d::Image::preload(const String& fileName)
|
||||||
WICBitmapPaletteTypeMedianCut
|
WICBitmapPaletteTypeMedianCut
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
// 从 WIC 位图创建一个 Direct2D 位图
|
// 从 WIC 位图创建一个 Direct2D 位图
|
||||||
|
|
@ -213,6 +215,7 @@ bool e2d::Image::preload(const String& fileName)
|
||||||
&pBitmap
|
&pBitmap
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
// 保存图片指针和图片的 Hash 名
|
// 保存图片指针和图片的 Hash 名
|
||||||
|
|
|
||||||
|
|
@ -50,9 +50,9 @@ void e2d::Scene::add(Node * child, int order /* = 0 */)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
#ifdef HIGHER_THAN_VS2012
|
||||||
void e2d::Scene::add(const std::initializer_list<Node*>& vNodes, int order)
|
void e2d::Scene::add(const std::initializer_list<Node*>& nodes, int order)
|
||||||
{
|
{
|
||||||
for (const auto &node : vNodes)
|
for (const auto &node : nodes)
|
||||||
{
|
{
|
||||||
this->add(node, order);
|
this->add(node, order);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -213,15 +213,15 @@ void e2d::ActionManager::stopAll()
|
||||||
|
|
||||||
std::vector<e2d::Action*> e2d::ActionManager::get(const String& strActionName)
|
std::vector<e2d::Action*> e2d::ActionManager::get(const String& strActionName)
|
||||||
{
|
{
|
||||||
std::vector<Action*> vActions;
|
std::vector<Action*> actions;
|
||||||
for (auto action : s_vActions)
|
for (auto action : s_vActions)
|
||||||
{
|
{
|
||||||
if (action->getName() == strActionName)
|
if (action->getName() == strActionName)
|
||||||
{
|
{
|
||||||
vActions.push_back(action);
|
actions.push_back(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return std::move(vActions);
|
return std::move(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<e2d::Action*> e2d::ActionManager::getAll()
|
std::vector<e2d::Action*> e2d::ActionManager::getAll()
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ void e2d::SceneManager::enter(Scene * scene, Transition * transition /* = nullpt
|
||||||
// 保存下一场景的指针
|
// 保存下一场景的指针
|
||||||
s_pNextScene = scene;
|
s_pNextScene = scene;
|
||||||
|
|
||||||
// 设置切换场景动画
|
// 设置切换场景动作
|
||||||
if (transition)
|
if (transition)
|
||||||
{
|
{
|
||||||
if (s_pTransition)
|
if (s_pTransition)
|
||||||
|
|
@ -52,7 +52,7 @@ void e2d::SceneManager::back(Transition * transition /* = nullptr */)
|
||||||
s_bSaveCurrScene = false;
|
s_bSaveCurrScene = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置切换场景动画
|
// 设置切换场景动作
|
||||||
if (transition)
|
if (transition)
|
||||||
{
|
{
|
||||||
s_pTransition = transition;
|
s_pTransition = transition;
|
||||||
|
|
@ -100,7 +100,7 @@ void e2d::SceneManager::__update()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 更新场景动画
|
// 更新场景动作
|
||||||
s_pTransition->_update();
|
s_pTransition->_update();
|
||||||
|
|
||||||
if (s_pTransition->isDone())
|
if (s_pTransition->isDone())
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,21 @@ e2d::Menu::Menu()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
e2d::Menu::Menu(int number, Button * button1, ...)
|
||||||
|
: _enable(true)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, button1);
|
||||||
|
|
||||||
|
this->addButton(button1);
|
||||||
|
for (int i = 1; i < number; i++)
|
||||||
|
{
|
||||||
|
this->addButton(va_arg(args, Button*));
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
#ifdef HIGHER_THAN_VS2012
|
||||||
e2d::Menu::Menu(const std::initializer_list<Button*>& vButtons)
|
e2d::Menu::Menu(const std::initializer_list<Button*>& vButtons)
|
||||||
: _enable(true)
|
: _enable(true)
|
||||||
|
|
@ -14,21 +29,6 @@ e2d::Menu::Menu(const std::initializer_list<Button*>& vButtons)
|
||||||
this->addButton(button);
|
this->addButton(button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
e2d::Menu::Menu(int number, Button * button1, ...)
|
|
||||||
: _enable(true)
|
|
||||||
{
|
|
||||||
Button ** ppButton = &button1;
|
|
||||||
|
|
||||||
while (number > 0)
|
|
||||||
{
|
|
||||||
this->addButton(*ppButton);
|
|
||||||
ppButton++;
|
|
||||||
number--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool e2d::Menu::isEnable() const
|
bool e2d::Menu::isEnable() const
|
||||||
|
|
|
||||||
|
|
@ -597,10 +597,24 @@ void e2d::Node::addColliableName(const String& collliderName)
|
||||||
_colliders.insert(hash);
|
_colliders.insert(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
void e2d::Node::addColliableName(int number, String collliderName, ...)
|
||||||
void e2d::Node::addColliableName(const std::initializer_list<String>& vCollliderName)
|
|
||||||
{
|
{
|
||||||
for (const auto &name : vCollliderName)
|
va_list args;
|
||||||
|
va_start(args, collliderName);
|
||||||
|
|
||||||
|
this->addColliableName(collliderName);
|
||||||
|
for (int i = 1; i < number; i++)
|
||||||
|
{
|
||||||
|
this->addColliableName(va_arg(args, String));
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
void e2d::Node::addColliableName(const std::initializer_list<String>& colliderNames)
|
||||||
|
{
|
||||||
|
for (const auto &name : colliderNames)
|
||||||
{
|
{
|
||||||
this->addColliableName(name);
|
this->addColliableName(name);
|
||||||
}
|
}
|
||||||
|
|
@ -649,9 +663,9 @@ void e2d::Node::addChild(Node * child, int order /* = 0 */)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
#ifdef HIGHER_THAN_VS2012
|
||||||
void e2d::Node::addChild(const std::initializer_list<Node*>& vNodes, int order)
|
void e2d::Node::addChild(const std::initializer_list<Node*>& nodes, int order)
|
||||||
{
|
{
|
||||||
for (const auto &node : vNodes)
|
for (const auto &node : nodes)
|
||||||
{
|
{
|
||||||
this->addChild(node, order);
|
this->addChild(node, order);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ void e2d::Transition::_init(Scene * prev, Scene * next)
|
||||||
|
|
||||||
void e2d::Transition::_update()
|
void e2d::Transition::_update()
|
||||||
{
|
{
|
||||||
// 计算动画进度
|
// 计算动作进度
|
||||||
if (_duration == 0)
|
if (_duration == 0)
|
||||||
{
|
{
|
||||||
_delta = 1;
|
_delta = 1;
|
||||||
|
|
|
||||||
259
core/e2daction.h
259
core/e2daction.h
|
|
@ -70,7 +70,7 @@ protected:
|
||||||
// 获取动作结束状态
|
// 获取动作结束状态
|
||||||
virtual bool _isDone();
|
virtual bool _isDone();
|
||||||
|
|
||||||
// 重置动画时间
|
// 重置动作时间
|
||||||
virtual void _resetTime();
|
virtual void _resetTime();
|
||||||
|
|
||||||
// 开始动作
|
// 开始动作
|
||||||
|
|
@ -93,16 +93,16 @@ class ActionGradual :
|
||||||
public Action
|
public Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建特定时长的持续动画
|
// 创建特定时长的持续动作
|
||||||
ActionGradual(
|
ActionGradual(
|
||||||
double duration
|
double duration
|
||||||
);
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 初始化动画
|
// 初始化动作
|
||||||
virtual void _init() override;
|
virtual void _init() override;
|
||||||
|
|
||||||
// 更新动画
|
// 更新动作
|
||||||
virtual void _update() override;
|
virtual void _update() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -111,28 +111,28 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 相对位移动画
|
// 相对位移动作
|
||||||
class MoveBy :
|
class MoveBy :
|
||||||
public ActionGradual
|
public ActionGradual
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建相对位移动画
|
// 创建相对位移动作
|
||||||
MoveBy(
|
MoveBy(
|
||||||
double duration, /* 动画持续时长 */
|
double duration, /* 动作持续时长 */
|
||||||
Vector vector /* 位移向量 */
|
Vector vector /* 位移向量 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动画的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
virtual MoveBy * clone() const override;
|
virtual MoveBy * clone() const override;
|
||||||
|
|
||||||
// 获取该动画的倒转
|
// 获取该动作的倒转
|
||||||
virtual MoveBy * reverse() const override;
|
virtual MoveBy * reverse() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 初始化动画
|
// 初始化动作
|
||||||
virtual void _init() override;
|
virtual void _init() override;
|
||||||
|
|
||||||
// 执行动画
|
// 执行动作
|
||||||
virtual void _update() override;
|
virtual void _update() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -141,22 +141,22 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 位移动画
|
// 位移动作
|
||||||
class MoveTo :
|
class MoveTo :
|
||||||
public MoveBy
|
public MoveBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建位移动画
|
// 创建位移动作
|
||||||
MoveTo(
|
MoveTo(
|
||||||
double duration, /* 动画持续时长 */
|
double duration, /* 动作持续时长 */
|
||||||
Point pos /* 位移至目标点的坐标 */
|
Point pos /* 位移至目标点的坐标 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动画的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
virtual MoveTo * clone() const override;
|
virtual MoveTo * clone() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 初始化动画
|
// 初始化动作
|
||||||
virtual void _init() override;
|
virtual void _init() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -164,35 +164,35 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 相对缩放动画
|
// 相对缩放动作
|
||||||
class ScaleBy :
|
class ScaleBy :
|
||||||
public ActionGradual
|
public ActionGradual
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建相对缩放动画
|
// 创建相对缩放动作
|
||||||
ScaleBy(
|
ScaleBy(
|
||||||
double duration, /* 动画持续时长 */
|
double duration, /* 动作持续时长 */
|
||||||
double scale /* 缩放比例变化 */
|
double scale /* 缩放比例变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 创建相对缩放动画
|
// 创建相对缩放动作
|
||||||
ScaleBy(
|
ScaleBy(
|
||||||
double duration, /* 动画持续时长 */
|
double duration, /* 动作持续时长 */
|
||||||
double scaleX, /* 横向缩放比例变化 */
|
double scaleX, /* 横向缩放比例变化 */
|
||||||
double scaleY /* 纵向缩放比例变化 */
|
double scaleY /* 纵向缩放比例变化 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动画的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
virtual ScaleBy * clone() const override;
|
virtual ScaleBy * clone() const override;
|
||||||
|
|
||||||
// 获取该动画的倒转
|
// 获取该动作的倒转
|
||||||
virtual ScaleBy * reverse() const override;
|
virtual ScaleBy * reverse() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 初始化动画
|
// 初始化动作
|
||||||
virtual void _init() override;
|
virtual void _init() override;
|
||||||
|
|
||||||
// 执行动画
|
// 执行动作
|
||||||
virtual void _update() override;
|
virtual void _update() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -203,29 +203,29 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 缩放动画
|
// 缩放动作
|
||||||
class ScaleTo :
|
class ScaleTo :
|
||||||
public ScaleBy
|
public ScaleBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建缩放动画
|
// 创建缩放动作
|
||||||
ScaleTo(
|
ScaleTo(
|
||||||
double duration, /* 动画持续时长 */
|
double duration, /* 动作持续时长 */
|
||||||
double scale /* 缩放至目标比例 */
|
double scale /* 缩放至目标比例 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 创建缩放动画
|
// 创建缩放动作
|
||||||
ScaleTo(
|
ScaleTo(
|
||||||
double duration, /* 动画持续时长 */
|
double duration, /* 动作持续时长 */
|
||||||
double scaleX, /* 横向缩放至目标比例 */
|
double scaleX, /* 横向缩放至目标比例 */
|
||||||
double scaleY /* 纵向缩放至目标比例 */
|
double scaleY /* 纵向缩放至目标比例 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动画的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
virtual ScaleTo * clone() const override;
|
virtual ScaleTo * clone() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 初始化动画
|
// 初始化动作
|
||||||
virtual void _init() override;
|
virtual void _init() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -234,28 +234,28 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 透明度相对渐变动画
|
// 透明度相对渐变动作
|
||||||
class OpacityBy :
|
class OpacityBy :
|
||||||
public ActionGradual
|
public ActionGradual
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建透明度相对渐变动画
|
// 创建透明度相对渐变动作
|
||||||
OpacityBy(
|
OpacityBy(
|
||||||
double duration, /* 动画持续时长 */
|
double duration, /* 动作持续时长 */
|
||||||
double opacity /* 透明度相对变化值 */
|
double opacity /* 透明度相对变化值 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动画的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
virtual OpacityBy * clone() const override;
|
virtual OpacityBy * clone() const override;
|
||||||
|
|
||||||
// 获取该动画的倒转
|
// 获取该动作的倒转
|
||||||
virtual OpacityBy * reverse() const override;
|
virtual OpacityBy * reverse() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 初始化动画
|
// 初始化动作
|
||||||
virtual void _init() override;
|
virtual void _init() override;
|
||||||
|
|
||||||
// 执行动画
|
// 执行动作
|
||||||
virtual void _update() override;
|
virtual void _update() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -264,22 +264,22 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 透明度渐变动画
|
// 透明度渐变动作
|
||||||
class OpacityTo :
|
class OpacityTo :
|
||||||
public OpacityBy
|
public OpacityBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建透明度渐变动画
|
// 创建透明度渐变动作
|
||||||
OpacityTo(
|
OpacityTo(
|
||||||
double duration, /* 动画持续时长 */
|
double duration, /* 动作持续时长 */
|
||||||
double opacity /* 透明度渐变至目标值 */
|
double opacity /* 透明度渐变至目标值 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动画的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
virtual OpacityTo * clone() const override;
|
virtual OpacityTo * clone() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 初始化动画
|
// 初始化动作
|
||||||
virtual void _init() override;
|
virtual void _init() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -287,14 +287,14 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 淡入动画
|
// 淡入动作
|
||||||
class FadeIn :
|
class FadeIn :
|
||||||
public OpacityTo
|
public OpacityTo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建淡入动画
|
// 创建淡入动作
|
||||||
FadeIn(
|
FadeIn(
|
||||||
double duration /* 动画持续时长 */
|
double duration /* 动作持续时长 */
|
||||||
)
|
)
|
||||||
: OpacityTo(duration, 1)
|
: OpacityTo(duration, 1)
|
||||||
{
|
{
|
||||||
|
|
@ -302,14 +302,14 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 淡出动画
|
// 淡出动作
|
||||||
class FadeOut :
|
class FadeOut :
|
||||||
public OpacityTo
|
public OpacityTo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建淡出动画
|
// 创建淡出动作
|
||||||
FadeOut(
|
FadeOut(
|
||||||
double duration /* 动画持续时长 */
|
double duration /* 动作持续时长 */
|
||||||
)
|
)
|
||||||
: OpacityTo(duration, 0)
|
: OpacityTo(duration, 0)
|
||||||
{
|
{
|
||||||
|
|
@ -322,23 +322,23 @@ class RotateBy :
|
||||||
public ActionGradual
|
public ActionGradual
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建相对旋转动画
|
// 创建相对旋转动作
|
||||||
RotateBy(
|
RotateBy(
|
||||||
double duration, /* 动画持续时长 */
|
double duration, /* 动作持续时长 */
|
||||||
double rotation /* 旋转角度变化值 */
|
double rotation /* 旋转角度变化值 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动画的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
virtual RotateBy * clone() const override;
|
virtual RotateBy * clone() const override;
|
||||||
|
|
||||||
// 获取该动画的倒转
|
// 获取该动作的倒转
|
||||||
virtual RotateBy * reverse() const override;
|
virtual RotateBy * reverse() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 初始化动画
|
// 初始化动作
|
||||||
virtual void _init() override;
|
virtual void _init() override;
|
||||||
|
|
||||||
// 执行动画
|
// 执行动作
|
||||||
virtual void _update() override;
|
virtual void _update() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -352,17 +352,17 @@ class RotateTo :
|
||||||
public RotateBy
|
public RotateBy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建旋转动画
|
// 创建旋转动作
|
||||||
RotateTo(
|
RotateTo(
|
||||||
double duration, /* 动画持续时长 */
|
double duration, /* 动作持续时长 */
|
||||||
double rotation /* 旋转角度至目标值 */
|
double rotation /* 旋转角度至目标值 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取该动画的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
virtual RotateTo * clone() const override;
|
virtual RotateTo * clone() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 初始化动画
|
// 初始化动作
|
||||||
virtual void _init() override;
|
virtual void _init() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -424,7 +424,7 @@ protected:
|
||||||
// 执行动作
|
// 执行动作
|
||||||
virtual void _update() override;
|
virtual void _update() override;
|
||||||
|
|
||||||
// 重置动画时间
|
// 重置动作时间
|
||||||
virtual void _resetTime() override;
|
virtual void _resetTime() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -467,18 +467,18 @@ public:
|
||||||
// 创建顺序动作
|
// 创建顺序动作
|
||||||
Sequence();
|
Sequence();
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
|
||||||
// 创建顺序动作
|
|
||||||
Sequence(
|
|
||||||
const std::initializer_list<Action*>& vActions /* 动作列表 */
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
// 创建顺序动作
|
// 创建顺序动作
|
||||||
Sequence(
|
Sequence(
|
||||||
int number, /* 动作数量 */
|
int number, /* 动作数量 */
|
||||||
Action * action, /* 第一个动作 */
|
Action * action, /* 第一个动作 */
|
||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
// 创建顺序动作
|
||||||
|
Sequence(
|
||||||
|
const std::initializer_list<Action*>& actions /* 动作列表 */
|
||||||
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual ~Sequence();
|
virtual ~Sequence();
|
||||||
|
|
@ -488,18 +488,18 @@ public:
|
||||||
Action * action
|
Action * action
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
|
||||||
// 在结尾添加多个动作
|
|
||||||
void add(
|
|
||||||
const std::initializer_list<Action*>& vActions /* 动作列表 */
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
// 在结尾添加多个动作
|
// 在结尾添加多个动作
|
||||||
void add(
|
void add(
|
||||||
int number, /* 动作数量 */
|
int number, /* 动作数量 */
|
||||||
Action * action, /* 第一个动作 */
|
Action * action, /* 第一个动作 */
|
||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
// 在结尾添加多个动作
|
||||||
|
void add(
|
||||||
|
const std::initializer_list<Action*>& actions /* 动作列表 */
|
||||||
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -521,7 +521,7 @@ protected:
|
||||||
// 执行动作
|
// 执行动作
|
||||||
virtual void _update() override;
|
virtual void _update() override;
|
||||||
|
|
||||||
// 重置动画时间
|
// 重置动作时间
|
||||||
virtual void _resetTime() override;
|
virtual void _resetTime() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -538,18 +538,18 @@ public:
|
||||||
// 创建同步动作
|
// 创建同步动作
|
||||||
Spawn();
|
Spawn();
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
|
||||||
// 创建同步动作
|
|
||||||
Spawn(
|
|
||||||
const std::initializer_list<Action*>& vActions /* 动作列表 */
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
// 创建同步动作
|
// 创建同步动作
|
||||||
Spawn(
|
Spawn(
|
||||||
int number, /* 动作数量 */
|
int number, /* 动作数量 */
|
||||||
Action * action, /* 第一个动作 */
|
Action * action, /* 第一个动作 */
|
||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
// 创建同步动作
|
||||||
|
Spawn(
|
||||||
|
const std::initializer_list<Action*>& actions /* 动作列表 */
|
||||||
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
virtual ~Spawn();
|
virtual ~Spawn();
|
||||||
|
|
@ -559,18 +559,18 @@ public:
|
||||||
Action * action
|
Action * action
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
|
||||||
// 在结尾添加多个动作
|
|
||||||
void add(
|
|
||||||
const std::initializer_list<Action*>& vActions /* 动作列表 */
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
// 在结尾添加多个动作
|
// 在结尾添加多个动作
|
||||||
void add(
|
void add(
|
||||||
int number, /* 动作数量 */
|
int number, /* 动作数量 */
|
||||||
Action * action, /* 第一个动作 */
|
Action * action, /* 第一个动作 */
|
||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
// 在结尾添加多个动作
|
||||||
|
void add(
|
||||||
|
const std::initializer_list<Action*>& actions /* 动作列表 */
|
||||||
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 获取该动作的拷贝对象
|
// 获取该动作的拷贝对象
|
||||||
|
|
@ -592,7 +592,7 @@ protected:
|
||||||
// 执行动作
|
// 执行动作
|
||||||
virtual void _update() override;
|
virtual void _update() override;
|
||||||
|
|
||||||
// 重置动画时间
|
// 重置动作时间
|
||||||
virtual void _resetTime() override;
|
virtual void _resetTime() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -600,78 +600,34 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 帧动画
|
// 精灵动作
|
||||||
class Animation :
|
class Animate :
|
||||||
public Action
|
public Action
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建帧动画
|
// 创建精灵动作
|
||||||
Animation();
|
Animate();
|
||||||
|
|
||||||
// 创建特定帧间隔的帧动画
|
// 创建精灵动作
|
||||||
Animation(
|
Animate(
|
||||||
double interval /* 帧间隔(秒) */
|
Animation * animation
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
virtual ~Animate();
|
||||||
// 创建帧动画
|
|
||||||
Animation(
|
// 获取动画
|
||||||
const std::initializer_list<Image*>& vImages /* 关键帧列表 */
|
virtual Animation * getAnimation() const;
|
||||||
|
|
||||||
|
// 设置动画
|
||||||
|
virtual void setAnimation(
|
||||||
|
Animation * animation
|
||||||
);
|
);
|
||||||
|
|
||||||
// 创建特定帧间隔的帧动画
|
// 获取该动作的拷贝对象
|
||||||
Animation(
|
virtual Animate * clone() const override;
|
||||||
double interval, /* 帧间隔(秒) */
|
|
||||||
const std::initializer_list<Image*>& vImages /* 关键帧列表 */
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
// 创建帧动画
|
|
||||||
Animation(
|
|
||||||
int number, /* 帧数量 */
|
|
||||||
Image * frame, /* 第一帧 */
|
|
||||||
...
|
|
||||||
);
|
|
||||||
|
|
||||||
// 创建特定帧间隔的帧动画
|
// 获取该动作的倒转
|
||||||
Animation(
|
virtual Animate * reverse() const override;
|
||||||
double interval, /* 帧间隔(秒) */
|
|
||||||
int number, /* 帧数量 */
|
|
||||||
Image * frame, /* 第一帧 */
|
|
||||||
...
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
virtual ~Animation();
|
|
||||||
|
|
||||||
// 添加关键帧
|
|
||||||
void add(
|
|
||||||
Image * frame /* 关键帧 */
|
|
||||||
);
|
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
|
||||||
// 添加多个关键帧
|
|
||||||
void add(
|
|
||||||
const std::initializer_list<Image*>& vImages /* 关键帧列表 */
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
// 添加多个关键帧
|
|
||||||
void add(
|
|
||||||
int number, /* 帧数量 */
|
|
||||||
Image * frame, /* 第一帧 */
|
|
||||||
...
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 设置每一帧的时间间隔
|
|
||||||
void setInterval(
|
|
||||||
double interval /* 帧间隔(秒) */
|
|
||||||
);
|
|
||||||
|
|
||||||
// 获取该动画的拷贝对象
|
|
||||||
virtual Animation * clone() const override;
|
|
||||||
|
|
||||||
// 获取该动画的倒转
|
|
||||||
virtual Animation * reverse() const override;
|
|
||||||
|
|
||||||
// 重置动作
|
// 重置动作
|
||||||
virtual void reset() override;
|
virtual void reset() override;
|
||||||
|
|
@ -687,9 +643,8 @@ protected:
|
||||||
virtual void _update() override;
|
virtual void _update() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double _interval;
|
|
||||||
UINT _frameIndex;
|
UINT _frameIndex;
|
||||||
std::vector<Image*> _frames;
|
Animation * _animation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -712,6 +712,97 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 帧动画
|
||||||
|
class Animation :
|
||||||
|
public Object
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// 创建帧动画
|
||||||
|
Animation();
|
||||||
|
|
||||||
|
// 创建特定间隔的帧动画
|
||||||
|
Animation(
|
||||||
|
double interval /* 帧间隔(秒) */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 创建特定帧间隔的帧动画
|
||||||
|
Animation(
|
||||||
|
double interval, /* 帧间隔(秒) */
|
||||||
|
const std::vector<Image*>& frames /* 关键帧数组 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 创建帧动画
|
||||||
|
Animation(
|
||||||
|
int number, /* 帧数量 */
|
||||||
|
Image * frame, /* 第一帧 */
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
// 创建特定帧间隔的帧动画
|
||||||
|
Animation(
|
||||||
|
double interval, /* 帧间隔(秒) */
|
||||||
|
int number, /* 帧数量 */
|
||||||
|
Image * frame, /* 第一帧 */
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
// 创建帧动画
|
||||||
|
Animation(
|
||||||
|
const std::initializer_list<Image*>& frames /* 关键帧列表 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 创建特定帧间隔的帧动画
|
||||||
|
Animation(
|
||||||
|
double interval, /* 帧间隔(秒) */
|
||||||
|
const std::initializer_list<Image*>& frames /* 关键帧列表 */
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
virtual ~Animation();
|
||||||
|
|
||||||
|
// 添加关键帧
|
||||||
|
void add(
|
||||||
|
Image * frame /* 关键帧 */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 添加多个关键帧
|
||||||
|
void add(
|
||||||
|
int number, /* 帧数量 */
|
||||||
|
Image * frame, /* 第一帧 */
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
// 添加多个关键帧
|
||||||
|
void add(
|
||||||
|
const std::initializer_list<Image*>& frames /* 关键帧列表 */
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 获取帧间隔
|
||||||
|
double getInterval() const;
|
||||||
|
|
||||||
|
// 获取关键帧
|
||||||
|
const std::vector<Image*>& getFrames() const;
|
||||||
|
|
||||||
|
// 设置每一帧的时间间隔
|
||||||
|
void setInterval(
|
||||||
|
double interval /* 帧间隔(秒) */
|
||||||
|
);
|
||||||
|
|
||||||
|
// 获取动画的拷贝对象
|
||||||
|
virtual Animation * clone() const;
|
||||||
|
|
||||||
|
// 销毁对象
|
||||||
|
virtual void onDestroy() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
double _interval;
|
||||||
|
std::vector<Image*> _frames;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class Node;
|
class Node;
|
||||||
class SceneManager;
|
class SceneManager;
|
||||||
class Transition;
|
class Transition;
|
||||||
|
|
@ -760,7 +851,7 @@ public:
|
||||||
#ifdef HIGHER_THAN_VS2012
|
#ifdef HIGHER_THAN_VS2012
|
||||||
// 添加多个节点到场景
|
// 添加多个节点到场景
|
||||||
virtual void add(
|
virtual void add(
|
||||||
const std::initializer_list<Node*>& vNodes, /* 节点列表 */
|
const std::initializer_list<Node*>& nodes, /* 节点列表 */
|
||||||
int order = 0 /* 渲染顺序 */
|
int order = 0 /* 渲染顺序 */
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,13 @@ public:
|
||||||
// 切换场景
|
// 切换场景
|
||||||
static void enter(
|
static void enter(
|
||||||
Scene * scene, /* 下一个场景的指针 */
|
Scene * scene, /* 下一个场景的指针 */
|
||||||
Transition * transition = nullptr, /* 场景切换动画 */
|
Transition * transition = nullptr, /* 场景切换动作 */
|
||||||
bool saveCurrentScene = true /* 是否保存当前场景 */
|
bool saveCurrentScene = true /* 是否保存当前场景 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 返回上一场景
|
// 返回上一场景
|
||||||
static void back(
|
static void back(
|
||||||
Transition * transition = nullptr /* 场景切换动画 */
|
Transition * transition = nullptr /* 场景切换动作 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 清空保存的所有场景
|
// 清空保存的所有场景
|
||||||
|
|
@ -67,7 +67,7 @@ public:
|
||||||
// 获取场景栈
|
// 获取场景栈
|
||||||
static std::stack<Scene*> getSceneStack();
|
static std::stack<Scene*> getSceneStack();
|
||||||
|
|
||||||
// 是否正在进行转场动画
|
// 是否正在进行转场动作
|
||||||
static bool isTransitioning();
|
static bool isTransitioning();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -133,7 +133,7 @@ public:
|
||||||
static std::vector<Action*> getAll();
|
static std::vector<Action*> getAll();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// 更新动画状态
|
// 更新动作状态
|
||||||
static void __update();
|
static void __update();
|
||||||
|
|
||||||
// 添加动作
|
// 添加动作
|
||||||
|
|
|
||||||
|
|
@ -338,10 +338,17 @@ public:
|
||||||
const String& collliderName
|
const String& collliderName
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 添加多个可碰撞节点的名称
|
||||||
|
virtual void addColliableName(
|
||||||
|
int number, /* 名称数量 */
|
||||||
|
String collliderName, /* 第一个名称 */
|
||||||
|
...
|
||||||
|
);
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
#ifdef HIGHER_THAN_VS2012
|
||||||
// 添加多个可碰撞节点的名称
|
// 添加多个可碰撞节点的名称
|
||||||
virtual void addColliableName(
|
virtual void addColliableName(
|
||||||
const std::initializer_list<String>& vCollliderName /* 名称列表 */
|
const std::initializer_list<String>& colliderNames /* 名称列表 */
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -359,48 +366,48 @@ public:
|
||||||
#ifdef HIGHER_THAN_VS2012
|
#ifdef HIGHER_THAN_VS2012
|
||||||
// 添加多个子节点
|
// 添加多个子节点
|
||||||
virtual void addChild(
|
virtual void addChild(
|
||||||
const std::initializer_list<Node*>& vNodes, /* 节点列表 */
|
const std::initializer_list<Node*>& nodes, /* 节点列表 */
|
||||||
int order = 0 /* 渲染顺序 */
|
int order = 0 /* 渲染顺序 */
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 执行动画
|
// 执行动作
|
||||||
virtual void runAction(
|
virtual void runAction(
|
||||||
Action * action
|
Action * action
|
||||||
);
|
);
|
||||||
|
|
||||||
// 继续动画
|
// 继续动作
|
||||||
virtual void resumeAction(
|
virtual void resumeAction(
|
||||||
const String& strActionName
|
const String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 暂停动画
|
// 暂停动作
|
||||||
virtual void pauseAction(
|
virtual void pauseAction(
|
||||||
const String& strActionName
|
const String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 停止动画
|
// 停止动作
|
||||||
virtual void stopAction(
|
virtual void stopAction(
|
||||||
const String& strActionName
|
const String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取名称相同的动画
|
// 获取名称相同的动作
|
||||||
virtual Action * getAction(
|
virtual Action * getAction(
|
||||||
const String& strActionName
|
const String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获取所有名称相同的动画
|
// 获取所有名称相同的动作
|
||||||
virtual std::vector<Action*> getActions(
|
virtual std::vector<Action*> getActions(
|
||||||
const String& strActionName
|
const String& strActionName
|
||||||
);
|
);
|
||||||
|
|
||||||
// 继续所有暂停动画
|
// 继续所有暂停动作
|
||||||
virtual void resumeAllActions();
|
virtual void resumeAllActions();
|
||||||
|
|
||||||
// 暂停所有动画
|
// 暂停所有动作
|
||||||
virtual void pauseAllActions();
|
virtual void pauseAllActions();
|
||||||
|
|
||||||
// 停止所有动画
|
// 停止所有动作
|
||||||
virtual void stopAllActions();
|
virtual void stopAllActions();
|
||||||
|
|
||||||
// 修改节点的默认中心点位置
|
// 修改节点的默认中心点位置
|
||||||
|
|
@ -958,18 +965,18 @@ public:
|
||||||
// 创建空菜单
|
// 创建空菜单
|
||||||
Menu();
|
Menu();
|
||||||
|
|
||||||
#ifdef HIGHER_THAN_VS2012
|
|
||||||
// 创建菜单
|
|
||||||
Menu(
|
|
||||||
const std::initializer_list<Button*>& vButtons /* 按钮列表 */
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
// 创建菜单
|
// 创建菜单
|
||||||
Menu(
|
Menu(
|
||||||
int number, /* 菜单中按钮的数量 */
|
int number, /* 菜单中按钮的数量 */
|
||||||
Button * button1, /* 第一个按钮 */
|
Button * button1, /* 第一个按钮 */
|
||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#ifdef HIGHER_THAN_VS2012
|
||||||
|
// 创建菜单
|
||||||
|
Menu(
|
||||||
|
const std::initializer_list<Button*>& vButtons /* 按钮列表 */
|
||||||
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 获取菜单是否禁用
|
// 获取菜单是否禁用
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ namespace e2d
|
||||||
class SceneManager;
|
class SceneManager;
|
||||||
|
|
||||||
|
|
||||||
// 基础过渡动画
|
// 基础过渡动作
|
||||||
class Transition :
|
class Transition :
|
||||||
public Object
|
public Object
|
||||||
{
|
{
|
||||||
|
|
@ -19,32 +19,32 @@ public:
|
||||||
|
|
||||||
virtual ~Transition();
|
virtual ~Transition();
|
||||||
|
|
||||||
// 场景切换动画是否结束
|
// 场景切换动作是否结束
|
||||||
bool isDone();
|
bool isDone();
|
||||||
|
|
||||||
// Ïú»Ù¶ÔÏó
|
// Ïú»Ù¶ÔÏó
|
||||||
virtual void onDestroy() override;
|
virtual void onDestroy() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 初始化场景动画
|
// 初始化场景动作
|
||||||
virtual void _init(
|
virtual void _init(
|
||||||
Scene * prev,
|
Scene * prev,
|
||||||
Scene * next
|
Scene * next
|
||||||
);
|
);
|
||||||
|
|
||||||
// 更新场景动画
|
// 更新场景动作
|
||||||
virtual void _update();
|
virtual void _update();
|
||||||
|
|
||||||
// 更新场景动画
|
// 更新场景动作
|
||||||
virtual void _updateCustom() = 0;
|
virtual void _updateCustom() = 0;
|
||||||
|
|
||||||
// 渲染场景动画
|
// 渲染场景动作
|
||||||
virtual void _render();
|
virtual void _render();
|
||||||
|
|
||||||
// 重置场景动画
|
// 重置场景动作
|
||||||
virtual void _reset() = 0;
|
virtual void _reset() = 0;
|
||||||
|
|
||||||
// 停止场景动画
|
// 停止场景动作
|
||||||
virtual void _stop();
|
virtual void _stop();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -66,19 +66,19 @@ class TransitionFade :
|
||||||
public Transition
|
public Transition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建淡入淡出式的场景切换动画
|
// 创建淡入淡出式的场景切换动作
|
||||||
TransitionFade(
|
TransitionFade(
|
||||||
double duration /* 动画持续时长 */
|
double duration /* 动作持续时长 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 创建淡入淡出式的场景切换动画
|
// 创建淡入淡出式的场景切换动作
|
||||||
TransitionFade(
|
TransitionFade(
|
||||||
double fadeOutDuration, /* 前一场景淡出动画持续时长 */
|
double fadeOutDuration, /* 前一场景淡出动作持续时长 */
|
||||||
double fadeInDuration /* 后一场景淡入动画持续时长 */
|
double fadeInDuration /* 后一场景淡入动作持续时长 */
|
||||||
);
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 更新动画
|
// 更新动作
|
||||||
virtual void _updateCustom() override;
|
virtual void _updateCustom() override;
|
||||||
|
|
||||||
virtual void _init(
|
virtual void _init(
|
||||||
|
|
@ -99,13 +99,13 @@ class TransitionEmerge :
|
||||||
public Transition
|
public Transition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建浮现式的场景切换动画
|
// 创建浮现式的场景切换动作
|
||||||
TransitionEmerge(
|
TransitionEmerge(
|
||||||
double duration /* 浮现动画持续时长 */
|
double duration /* 浮现动作持续时长 */
|
||||||
);
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 更新动画
|
// 更新动作
|
||||||
virtual void _updateCustom() override;
|
virtual void _updateCustom() override;
|
||||||
|
|
||||||
virtual void _init(
|
virtual void _init(
|
||||||
|
|
@ -121,14 +121,14 @@ class TransitionMove :
|
||||||
public Transition
|
public Transition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// 创建移动式的场景切换动画
|
// 创建移动式的场景切换动作
|
||||||
TransitionMove(
|
TransitionMove(
|
||||||
double moveDuration, /* 场景移动动画持续时长 */
|
double moveDuration, /* 场景移动动作持续时长 */
|
||||||
Direction direction = Direction::LEFT /* ³¡¾°Òƶ¯·½Ïò */
|
Direction direction = Direction::LEFT /* ³¡¾°Òƶ¯·½Ïò */
|
||||||
);
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// 更新动画
|
// 更新动作
|
||||||
virtual void _updateCustom() override;
|
virtual void _updateCustom() override;
|
||||||
|
|
||||||
virtual void _init(
|
virtual void _init(
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@
|
||||||
<ClCompile Include="..\..\core\Action\CallFunc.cpp" />
|
<ClCompile Include="..\..\core\Action\CallFunc.cpp" />
|
||||||
<ClCompile Include="..\..\core\Action\Delay.cpp" />
|
<ClCompile Include="..\..\core\Action\Delay.cpp" />
|
||||||
<ClCompile Include="..\..\core\Action\MoveBy.cpp" />
|
<ClCompile Include="..\..\core\Action\MoveBy.cpp" />
|
||||||
<ClCompile Include="..\..\core\Action\Animation.cpp" />
|
<ClCompile Include="..\..\core\Action\Animate.cpp" />
|
||||||
<ClCompile Include="..\..\core\Action\MoveTo.cpp" />
|
<ClCompile Include="..\..\core\Action\MoveTo.cpp" />
|
||||||
<ClCompile Include="..\..\core\Action\Loop.cpp" />
|
<ClCompile Include="..\..\core\Action\Loop.cpp" />
|
||||||
<ClCompile Include="..\..\core\Action\OpacityBy.cpp" />
|
<ClCompile Include="..\..\core\Action\OpacityBy.cpp" />
|
||||||
|
|
@ -221,6 +221,7 @@
|
||||||
<ClCompile Include="..\..\core\Collider\ColliderCircle.cpp" />
|
<ClCompile Include="..\..\core\Collider\ColliderCircle.cpp" />
|
||||||
<ClCompile Include="..\..\core\Collider\ColliderEllipse.cpp" />
|
<ClCompile Include="..\..\core\Collider\ColliderEllipse.cpp" />
|
||||||
<ClCompile Include="..\..\core\Collider\ColliderRect.cpp" />
|
<ClCompile Include="..\..\core\Collider\ColliderRect.cpp" />
|
||||||
|
<ClCompile Include="..\..\core\Common\Animation.cpp" />
|
||||||
<ClCompile Include="..\..\core\Common\Color.cpp" />
|
<ClCompile Include="..\..\core\Common\Color.cpp" />
|
||||||
<ClCompile Include="..\..\core\Common\Function.cpp" />
|
<ClCompile Include="..\..\core\Common\Function.cpp" />
|
||||||
<ClCompile Include="..\..\core\Common\TextStyle.cpp" />
|
<ClCompile Include="..\..\core\Common\TextStyle.cpp" />
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,6 @@
|
||||||
<ClCompile Include="..\..\core\Action\ActionGradual.cpp">
|
<ClCompile Include="..\..\core\Action\ActionGradual.cpp">
|
||||||
<Filter>Action</Filter>
|
<Filter>Action</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\core\Action\Animation.cpp">
|
|
||||||
<Filter>Action</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\core\Common\Image.cpp">
|
<ClCompile Include="..\..\core\Common\Image.cpp">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
@ -213,6 +210,12 @@
|
||||||
<ClCompile Include="..\..\core\Transition\Transition.cpp">
|
<ClCompile Include="..\..\core\Transition\Transition.cpp">
|
||||||
<Filter>Transition</Filter>
|
<Filter>Transition</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Action\Animate.cpp">
|
||||||
|
<Filter>Action</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\core\Common\Animation.cpp">
|
||||||
|
<Filter>Common</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\core\easy2d.h" />
|
<ClInclude Include="..\..\core\easy2d.h" />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue