-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimatedSprite.cpp
More file actions
33 lines (32 loc) · 885 Bytes
/
animatedSprite.cpp
File metadata and controls
33 lines (32 loc) · 885 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "animatedSprite.h"
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include "util.h"
void Animated_Sprite::zrob_sprite(){
auto texture_sprite = wczytaj_texture(this->spriteFile);
texture_sprite->setSmooth(smooth);
sprite.setTexture(*texture_sprite);
sprite.setScale(scale, scale);
sprite.setTextureRect(textureRect);
sprite.setPosition(x, y);
};
void Animated_Sprite::draw_sprite(sf::RenderWindow *window)
{
window->draw(sprite);
}
void Animated_Sprite::add_animation_frame(sf::IntRect new_animation)
{
animations.emplace_back(new_animation);
}
void Animated_Sprite::set_animation(int number)
{
this->sprite.setTextureRect(animations[number]);
}
void Animated_Sprite::set_animation_still()
{
this->sprite.setTextureRect(textureRect);
}
sf::FloatRect Animated_Sprite::Get_bounds()
{
return this->sprite.getGlobalBounds();
}