Now have the ability to specify parameters needed.
This commit is contained in:
parent
949bbd4f15
commit
c4fcb41c34
3 changed files with 98 additions and 66 deletions
|
|
@ -45,37 +45,37 @@ namespace components {
|
|||
if(stationary) {
|
||||
switch(motion) {
|
||||
case ease::SHAKE: {
|
||||
pos_out.x += std::lerp(scale_x, max_scale, tick);
|
||||
pos_out.x += std::lerp(min_x, max_x, tick);
|
||||
} break;
|
||||
case ease::BOUNCE: {
|
||||
pos_out.y -= std::lerp(scale_y, max_scale, tick);
|
||||
pos_out.y -= std::lerp(min_y, max_y, tick);
|
||||
} break;
|
||||
case ease::RUSH: {
|
||||
scale_out.x = std::lerp(scale_x, max_scale, tick);
|
||||
scale_out.y = std::lerp(scale_y, max_scale, tick);
|
||||
scale_out.x = std::lerp(min_x, max_x, tick);
|
||||
scale_out.y = std::lerp(min_y, max_y, tick);
|
||||
pos_out.y = pos_out.y - (pos_out.y * scale_out.y - pos_out.y);
|
||||
} break;
|
||||
case ease::SQUEEZE: {
|
||||
scale_out.x *= std::lerp(scale_x, max_scale, tick);
|
||||
scale_out.x *= std::lerp(min_x, max_x, tick);
|
||||
|
||||
} break;
|
||||
case ease::SQUASH: {
|
||||
scale_out.y *= std::lerp(scale_y, max_scale, tick);
|
||||
scale_out.y *= std::lerp(min_y, max_y, tick);
|
||||
} break;
|
||||
case ease::STRETCH: {
|
||||
scale_out.x = std::lerp(scale_x, max_scale, tick);
|
||||
scale_out.x = std::lerp(min_x, max_x, tick);
|
||||
fmt::println("scale_x: {} max_scale: {} tick: {} scale_out.x: {}",
|
||||
scale_x, max_scale, tick, scale_out.x);
|
||||
min_x, max_x, tick, scale_out.x);
|
||||
} break;
|
||||
case ease::GROW: {
|
||||
scale_out.y = std::lerp(scale_y, max_scale, tick);
|
||||
scale_out.y = std::lerp(min_y, max_y, tick);
|
||||
} break;
|
||||
default:
|
||||
dbc::sentinel("Unknown animation.motion setting.");
|
||||
}
|
||||
} else {
|
||||
scale_out.x = std::lerp(scale_out.x * scale_x, scale_out.x * max_scale, tick);
|
||||
scale_out.y = std::lerp(scale_out.y * scale_y, scale_out.y * max_scale, tick);
|
||||
scale_out.x = std::lerp(scale_out.x * min_x, scale_out.x * max_x, tick);
|
||||
scale_out.y = std::lerp(scale_out.y * min_y, scale_out.y * max_y, tick);
|
||||
}
|
||||
|
||||
if(!simple) {
|
||||
|
|
@ -93,8 +93,8 @@ namespace components {
|
|||
rect_out.position.x += current * frame_width;
|
||||
}
|
||||
} else {
|
||||
scale_out.x = scale_x;
|
||||
scale_out.y = scale_y;
|
||||
scale_out.x = min_x;
|
||||
scale_out.y = min_y;
|
||||
playing = false;
|
||||
current = 0;
|
||||
subframe = 0.0f;
|
||||
|
|
@ -112,7 +112,7 @@ namespace animation {
|
|||
|
||||
bool apply(Animation& anim, sf::Sprite& sprite, sf::Vector2f pos) {
|
||||
sf::IntRect rect{{0,0}, {anim.frame_width, anim.frame_height}};
|
||||
sf::Vector2f scale{anim.scale_x, anim.scale_y};
|
||||
sf::Vector2f scale{anim.min_x, anim.min_y};
|
||||
|
||||
anim.step(scale, pos, rect);
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ namespace animation {
|
|||
sprite.setPosition(pos);
|
||||
|
||||
// BUG: make this an option: apply_scale, apply_position and ranges for x y
|
||||
if(anim.motion != ease::SHAKE && anim.motion != ease::BOUNCE && anim.motion != ease::RUSH) {
|
||||
if(anim.scaled) {
|
||||
sprite.setScale(scale);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue