made animations extremely precise
parent
71be55ee58
commit
01d89bfc66
|
@ -86,8 +86,10 @@ void Player::addWeapon(std::shared_ptr<Weapon> weapon) {
|
||||||
_weapons.back()->setReloadCallBack([this]() {
|
_weapons.back()->setReloadCallBack([this]() {
|
||||||
Timeline::animate(AnimationListTag("reload_weapon"),
|
Timeline::animate(AnimationListTag("reload_weapon"),
|
||||||
std::make_shared<ARotateLeft>(_weapons[_selectedWeapon],
|
std::make_shared<ARotateLeft>(_weapons[_selectedWeapon],
|
||||||
2 * Consts::PI,
|
10 * Consts::PI,
|
||||||
_weapons[_selectedWeapon]->reloadTime() / 2));
|
_weapons[_selectedWeapon]->reloadTime() / 2,
|
||||||
|
Animation::LoopOut::None,
|
||||||
|
Animation::InterpolationType::Linear));
|
||||||
});
|
});
|
||||||
|
|
||||||
// add call back function to create fire traces
|
// add call back function to create fire traces
|
||||||
|
|
|
@ -16,7 +16,14 @@ bool Animation::updateState() {
|
||||||
|
|
||||||
// linear normalized time:
|
// linear normalized time:
|
||||||
_dtime = Time::deltaTime() / _duration;
|
_dtime = Time::deltaTime() / _duration;
|
||||||
_time += _dtime;
|
|
||||||
|
if(_time + _dtime < 1.0) {
|
||||||
|
_time += _dtime;
|
||||||
|
} else {
|
||||||
|
_dtime = 1.0 - _time;
|
||||||
|
_time = 1.0 - _dtime;
|
||||||
|
_finished = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (_looped == LoopOut::Continue && _time > 0.5) {
|
if (_looped == LoopOut::Continue && _time > 0.5) {
|
||||||
_time = 0.5;
|
_time = 0.5;
|
||||||
|
@ -46,5 +53,5 @@ bool Animation::updateState() {
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
return (_time < 1) || _looped == LoopOut::Cycle;
|
return !_finished;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,12 @@ namespace Interpolation {
|
||||||
};
|
};
|
||||||
|
|
||||||
double Interpolation::Linear(double t) {
|
double Interpolation::Linear(double t) {
|
||||||
if (t < 0)
|
if (t < 0) {
|
||||||
t = -t;
|
t = -t;
|
||||||
return ((int) trunc(t) % 2) ? 1.0 - (t - trunc(t)) : (t - trunc(t));
|
}
|
||||||
|
int integer = static_cast<int>(t);
|
||||||
|
|
||||||
|
return (integer % 2) ? 1.0 - (t - integer) : (t - integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Interpolation::Cos(double t) {
|
double Interpolation::Cos(double t) {
|
||||||
|
|
Loading…
Reference in New Issue