-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhotload_sprite.hpp
35 lines (29 loc) · 1.13 KB
/
hotload_sprite.hpp
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
34
35
#pragma once
#include "texture_handle.hpp"
namespace rogue
{
// Code ripped from sf::Sprite, and comments removed from brievity
class HotloadSprite : public sf::Drawable, public sf::Transformable
{
public :
HotloadSprite();
explicit HotloadSprite(const TextureHandle& texture);
HotloadSprite(const TextureHandle& texture, const IntRect& rectangle);
void setTexture(const TextureHandle& texture, bool resetRect = false);
void setTextureRect(const IntRect& rectangle);
void setColor(const Color& color);
TextureHandle getTexture() const;
const IntRect& getTextureRect() const;
const Color& getColor() const;
sf::FloatRect getLocalBounds() const;
sf::FloatRect getGlobalBounds() const;
private :
virtual void draw(RenderTarget& target, sf::RenderStates states) const;
void updatePositions();
void updateTexCoords();
sf::Vertex m_vertices[4]; ///< Vertices defining the sprite's geometry
TextureHandle m_texture;
sf::IntRect m_textureRect; ///< Rectangle defining the area of the source texture to display
mutable Texture* m_lastTexture;
};
}