Working on how to do an idle 'breathing' animation for sprites.
This commit is contained in:
parent
2ecd8528ea
commit
26d313269c
3 changed files with 28 additions and 9 deletions
|
|
@ -17,7 +17,7 @@ namespace components {
|
|||
case ease::NONE:
|
||||
return 0.0;
|
||||
case ease::SINE:
|
||||
return tick;
|
||||
return std::abs(std::sin(subframe * ease_rate));
|
||||
case ease::OUT_CIRC:
|
||||
return ease::out_circ(tick);
|
||||
case ease::OUT_BOUNCE:
|
||||
|
|
@ -41,6 +41,7 @@ namespace components {
|
|||
|
||||
if(playing && current < frames) {
|
||||
float tick = twitching();
|
||||
fmt::print("tick: {}\r", tick);
|
||||
|
||||
if(stationary) {
|
||||
switch(motion) {
|
||||
|
|
@ -178,9 +179,9 @@ namespace animation {
|
|||
return MGR.animations.contains(name);
|
||||
}
|
||||
|
||||
Animation load(const std::string& name) {
|
||||
Animation load(const std::string& name, const std::string& state) {
|
||||
dbc::check(initialized, "You forgot to initialize animation.");
|
||||
return MGR.animations.at(name);
|
||||
return MGR.animations.at(name + state);
|
||||
}
|
||||
|
||||
void configure(DinkyECS::World& world, DinkyECS::Entity entity) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace animation {
|
|||
void center(sf::Sprite& target, sf::Vector2f pos);
|
||||
|
||||
void init();
|
||||
components::Animation load(const std::string& name);
|
||||
components::Animation load(const std::string& name, const std::string& state="");
|
||||
bool has(const std::string& name);
|
||||
void configure(DinkyECS::World& world, DinkyECS::Entity entity);
|
||||
void step_animation(DinkyECS::World& world, DinkyECS::Entity entity, sf::Vector2f& scale_out, sf::Vector2f& pos_out, sf::IntRect& rect_out);
|
||||
|
|
|
|||
|
|
@ -235,15 +235,33 @@
|
|||
"flipped": false,
|
||||
"looped": false
|
||||
},
|
||||
"rat_king_boss": {
|
||||
"_type": "Animation",
|
||||
"easing": 4,
|
||||
"motion": 0,
|
||||
"ease_rate": 0.5,
|
||||
"min_x": 0.6,
|
||||
"min_y": 0.6,
|
||||
"max_x": 0.8,
|
||||
"max_y": 0.8,
|
||||
"simple": false,
|
||||
"frames": 2,
|
||||
"speed": 0.02,
|
||||
"scaled": true,
|
||||
"stationary": true,
|
||||
"toggled": false,
|
||||
"flipped": false,
|
||||
"looped": false
|
||||
},
|
||||
"torch_fixture": {
|
||||
"_type": "Animation",
|
||||
"easing": 0,
|
||||
"motion": 0,
|
||||
"ease_rate": 0.5,
|
||||
"min_x": 0.5,
|
||||
"min_y": 0.5,
|
||||
"max_x": 0.5,
|
||||
"max_y": 0.5,
|
||||
"ease_rate": 0.1,
|
||||
"min_x": 0.6,
|
||||
"min_y": 0.6,
|
||||
"max_x": 0.6,
|
||||
"max_y": 0.6,
|
||||
"simple": false,
|
||||
"frames": 3,
|
||||
"speed": 0.2,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue