Animator now can apply transforms using the timer alpha which mostly works.
This commit is contained in:
parent
7f14a39edf
commit
785d0240da
4 changed files with 29 additions and 31 deletions
|
|
@ -161,10 +161,10 @@ animate2::Sequence sequence{
|
|||
};
|
||||
|
||||
animate2::Transform transform{
|
||||
.min_x{-40.0f},
|
||||
.min_y{-40.0f},
|
||||
.max_x{40.0f},
|
||||
.max_y{40.0f},
|
||||
.min_x{-20.0f},
|
||||
.min_y{-20.0f},
|
||||
.max_x{20.0f},
|
||||
.max_y{20.0f},
|
||||
.simple{false},
|
||||
.flipped{false},
|
||||
.ease_rate{0.5f},
|
||||
|
|
@ -173,7 +173,7 @@ animate2::Transform transform{
|
|||
.stationary{true},
|
||||
.toggled{false},
|
||||
.looped{true},
|
||||
.easing = ease2::out_circle,
|
||||
.easing = ease2::out_bounce,
|
||||
.motion = ease2::move_bounce,
|
||||
};
|
||||
|
||||
|
|
@ -204,16 +204,6 @@ int main(int argc, char* argv[]) {
|
|||
sf::Vector2f scale = sprite->getScale();
|
||||
|
||||
while(main.active()) {
|
||||
anim.apply(*sprite);
|
||||
|
||||
sf::Vector2f new_pos = pos;
|
||||
sf::Vector2f new_scale = scale;
|
||||
anim.motion(new_pos, new_scale);
|
||||
sprite->setPosition(new_pos);
|
||||
sprite->setScale(new_scale);
|
||||
|
||||
main.render();
|
||||
|
||||
auto [ticks, alpha] = timer.commit();
|
||||
fmt::println("TICK: {}, alpha: {}", ticks, alpha);
|
||||
|
||||
|
|
@ -222,8 +212,17 @@ int main(int argc, char* argv[]) {
|
|||
anim.update();
|
||||
}
|
||||
|
||||
// do something with alpha....
|
||||
anim.apply(*sprite);
|
||||
|
||||
sf::Vector2f new_pos = pos;
|
||||
sf::Vector2f new_scale = scale;
|
||||
anim.motion(new_pos, new_scale, alpha);
|
||||
sprite->setPosition(new_pos);
|
||||
sprite->setScale(new_scale);
|
||||
|
||||
main.render();
|
||||
|
||||
// do something with alpha....
|
||||
main.handle_keyboard_mouse();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue