Gamedev Framework (gf)
0.19.0
A C++17 framework for 2D games
include
gf
BasicSprite.h
1
/*
2
* Gamedev Framework (gf)
3
* Copyright (C) 2016-2021 Julien Bernard
4
*
5
* This software is provided 'as-is', without any express or implied
6
* warranty. In no event will the authors be held liable for any damages
7
* arising from the use of this software.
8
*
9
* Permission is granted to anyone to use this software for any purpose,
10
* including commercial applications, and to alter it and redistribute it
11
* freely, subject to the following restrictions:
12
*
13
* 1. The origin of this software must not be misrepresented; you must not
14
* claim that you wrote the original software. If you use this software
15
* in a product, an acknowledgment in the product documentation would be
16
* appreciated but is not required.
17
* 2. Altered source versions must be plainly marked as such, and must not be
18
* misrepresented as being the original software.
19
* 3. This notice may not be removed or altered from any source distribution.
20
*
21
* Part of this file comes from SFML, with the same license:
22
* Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
23
*/
24
#ifndef GF_BASIC_SPRITE_H
25
#define GF_BASIC_SPRITE_H
26
27
#include "GraphicsApi.h"
28
#include "Rect.h"
29
#include "Span.h"
30
31
namespace
gf
{
32
#ifndef DOXYGEN_SHOULD_SKIP_THIS
33
inline
namespace
v1 {
34
#endif
35
class
Texture
;
36
struct
Vertex;
37
46
class
GF_GRAPHICS_API
BasicSprite
{
47
public
:
53
BasicSprite
();
54
62
BasicSprite
(
const
Texture
& texture);
63
72
BasicSprite
(
const
Texture
& texture,
const
RectF
& textureRect);
73
92
void
setTexture(
const
Texture
& texture,
bool
resetRect =
false
);
93
104
const
Texture
&
getTexture
()
const
{
105
return
*m_texture;
106
}
107
115
bool
hasTexture
()
const
{
116
return
m_texture !=
nullptr
;
117
}
118
126
void
unsetTexture();
127
143
void
setTextureRect(
const
RectF
& rect);
144
152
const
RectF
&
getTextureRect
()
const
{
153
return
m_textureRect;
154
}
155
167
RectF
getLocalBounds()
const
;
168
169
170
void
updateGeometry(
Span<Vertex>
vertices);
171
172
private
:
173
const
Texture
*m_texture;
174
RectF
m_textureRect;
175
RectF
m_bounds;
176
};
177
178
#ifndef DOXYGEN_SHOULD_SKIP_THIS
179
}
180
#endif
181
}
182
183
#endif // GF_BASIC_SPRITE_H
gf::BasicSprite::hasTexture
bool hasTexture() const
Check if a texture is set.
Definition:
BasicSprite.h:115
gf::Span
A span.
Definition:
Span.h:36
gf::GraphicsTag::Texture
A GPU texture.
gf::Texture
A texture for colored images.
Definition:
Texture.h:313
gf::BasicSprite::getTextureRect
const RectF & getTextureRect() const
Get the sub-rectangle of the texture displayed by the sprite.
Definition:
BasicSprite.h:152
gf::Rect< float >
gf
The namespace for gf classes.
Definition:
Action.h:35
gf::BasicSprite::getTexture
const Texture & getTexture() const
Get the source texture of the sprite.
Definition:
BasicSprite.h:104
gf::BasicSprite
A basic sprite.
Definition:
BasicSprite.h:46
Generated by
1.8.13