22 #include "stage_node.h"
25 #include "../interfaces.h"
26 #include "../generic/managed.h"
27 #include "../generic/identifiable.h"
29 #include "../animation.h"
30 #include "../macros.h"
34 class KeyFrameAnimationState;
40 uint32_t padding_vertical = 0;
41 uint32_t padding_horizontal = 0;
53 using ContainerNode::_get_renderables;
56 void clean_up()
override;
57 void update(
float dt)
override;
59 bool destroy()
override;
60 bool destroy_immediately()
override;
64 void set_render_dimensions(
float width,
float height);
65 void set_render_dimensions_from_width(
float width);
66 void set_render_dimensions_from_height(
float height);
68 void set_render_priority(smlt::RenderPriority priority);
70 void set_alpha(
float alpha);
72 float alpha()
const {
return alpha_; }
73 MaterialID material_id()
const {
return material_id_; }
78 uint32_t frame_height,
82 void flip_vertically(
bool value=
true);
83 void flip_horizontally(
bool value=
true);
85 const AABB& aabb()
const override;
87 UniqueIDKey make_key()
const override {
88 return make_unique_id_key(
id());
93 float frame_width_ = 0;
94 float frame_height_ = 0;
95 float sprite_sheet_margin_ = 0;
96 float sprite_sheet_spacing_ = 0;
97 std::pair<uint32_t, uint32_t> sprite_sheet_padding_;
98 float render_width_ = 1.0;
99 float render_height_ = 1.0;
107 float image_width_ = 0;
108 float image_height_ = 0;
112 void update_texture_coordinates();
114 bool flipped_vertically_ =
false;
115 bool flipped_horizontally_ =
false;
117 void refresh_animation_state(uint32_t current_frame, uint32_t next_frame,
float interp) {
118 _S_UNUSED(current_frame);
119 _S_UNUSED(next_frame);
122 update_texture_coordinates();
125 std::shared_ptr<KeyFrameAnimationState> animation_state_;
129 Property<decltype(&Sprite::animation_state_)> animations = {
this, &Sprite::animation_state_};