Most of the transforms kind of work now need to hook in the new timer.
This commit is contained in:
parent
20d7612f1c
commit
7f14a39edf
6 changed files with 47 additions and 27 deletions
|
|
@ -55,6 +55,11 @@ namespace animator {
|
|||
bool mouse(float x, float y, guecs::Modifiers mods) {
|
||||
return $ui.mouse(x, y, mods);
|
||||
}
|
||||
|
||||
std::shared_ptr<sf::Sprite> get_sprite() {
|
||||
auto viewer = $ui.entity("viewer");
|
||||
return $ui.get<guecs::Sprite>(viewer).sprite;
|
||||
}
|
||||
};
|
||||
|
||||
enum class State {
|
||||
|
|
@ -156,10 +161,10 @@ animate2::Sequence sequence{
|
|||
};
|
||||
|
||||
animate2::Transform transform{
|
||||
.min_x{0.6f},
|
||||
.min_y{0.6f},
|
||||
.max_x{0.8f},
|
||||
.max_y{0.8f},
|
||||
.min_x{-40.0f},
|
||||
.min_y{-40.0f},
|
||||
.max_x{40.0f},
|
||||
.max_y{40.0f},
|
||||
.simple{false},
|
||||
.flipped{false},
|
||||
.ease_rate{0.5f},
|
||||
|
|
@ -168,8 +173,8 @@ animate2::Transform transform{
|
|||
.stationary{true},
|
||||
.toggled{false},
|
||||
.looped{true},
|
||||
.easing = ease2::in_out_back,
|
||||
.motion = ease2::move_rush,
|
||||
.easing = ease2::out_circle,
|
||||
.motion = ease2::move_bounce,
|
||||
};
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
|
@ -194,13 +199,19 @@ int main(int argc, char* argv[]) {
|
|||
timer.start();
|
||||
anim.play();
|
||||
|
||||
auto viewer = main.$ui.$ui.entity("viewer");
|
||||
auto& sprite = main.$ui.$ui.get<guecs::Sprite>(viewer).sprite;
|
||||
auto sprite = main.$ui.get_sprite();
|
||||
sf::Vector2f pos = sprite->getPosition();
|
||||
sf::Vector2f scale = sprite->getScale();
|
||||
|
||||
while(main.active()) {
|
||||
timer.begin();
|
||||
|
||||
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();
|
||||
|
|
@ -211,8 +222,8 @@ int main(int argc, char* argv[]) {
|
|||
anim.update();
|
||||
}
|
||||
|
||||
|
||||
// do something with alpha....
|
||||
|
||||
main.handle_keyboard_mouse();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue