11 :
SpriteAnimated(std::move(texture), frame_width, frame_height, row, steps, speed, 0, 0, 0.0) {
15 :
SpriteAnimated(std::move(texture), frame_width, frame_height, row, steps, speed, pos_x, pos_y, 0.0) {
19 :
game::core::
Sprite(std::move(texture), pos_x, pos_y, {frame_width/2, frame_height/2}, rotation, {0,
static_cast<float>(row - 1) * frame_height, frame_width, frame_height}) {
20 this->states_.push_back({row, steps, speed, frame_width, frame_height});
24 if(!visible && !update_if_invisible)
27 if(this->states_[state_].steps <= 1)
31 this->current_step_++;
33 if (this->current_step_ >= this->states_[this->state_].steps) {
34 this->current_step_ = 0;
38 this->frame_.x += this->states_[this->state_].frame_width;
43 this->states_.push_back({row, steps, speed, frame_width, frame_height});
47 this->state_ = this->next_state_;
48 this->frame_ = {0,
static_cast<float>(this->states_[this->state_].row - 1) * this->states_[this->state_].frame_height, this->states_[this->state_].frame_width, this->states_[this->state_].frame_height};
56 this->next_state_ = nextState;
The SpriteAnimated class enables frame-by-frame animations by displaying only a certain section of a ...
void Update() override
Updates the animation state of the sprite.
void AddState(int row, int steps, int speed, float frame_width, float frame_height)
Adds a new animation state.
void nextState(int nextState)
Switch to another animation state by its id. The switch will happen after the last animation cycle is...
The Sprite class specifies position and degree of rotation on the screen for an associated VRAM textu...
static long long int ticks
Global game counter. Can be used e.g. for the calculation of animation times.