Gamedev Framework (gf)
0.10.0
A C++14 framework for 2D games
include
gf
BasicSprite.h
1
/*
2
* Gamedev Framework (gf)
3
* Copyright (C) 2016-2018 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 "BufferRef.h"
28
#include "Portability.h"
29
#include "Rect.h"
30
31
namespace
gf
{
32
#ifndef DOXYGEN_SHOULD_SKIP_THIS
33
inline
namespace
v1 {
34
#endif
35
class
Texture;
36
struct
Vertex;
37
43
class
GF_API
BasicSprite
{
44
public
:
50
BasicSprite
();
51
59
BasicSprite
(
const
Texture
& texture);
60
69
BasicSprite
(
const
Texture
& texture,
const
RectF
& textureRect);
70
89
void
setTexture(
const
Texture
& texture,
bool
resetRect =
false
);
90
101
const
Texture
&
getTexture
()
const
{
102
return
*m_texture;
103
}
104
112
bool
hasTexture
()
const
{
113
return
m_texture !=
nullptr
;
114
}
115
123
void
unsetTexture();
124
140
void
setTextureRect(
const
RectF
& rect);
141
149
const
RectF
&
getTextureRect
()
const
{
150
return
m_textureRect;
151
}
152
164
RectF
getLocalBounds()
const
;
165
166
167
void
updateGeometry(
BufferRef<Vertex>
vertices);
168
169
private
:
170
const
Texture
*m_texture;
171
RectF
m_textureRect;
172
RectF
m_bounds;
173
};
174
175
#ifndef DOXYGEN_SHOULD_SKIP_THIS
176
}
177
#endif
178
}
179
180
#endif // GF_BASIC_SPRITE_H
gf::BasicSprite::hasTexture
bool hasTexture() const
Check if a texture is set.
Definition:
BasicSprite.h:112
gf::BufferRef
A reference to a modifiable buffer and its size.
Definition:
BufferRef.h:43
gf::Texture
A texture for colored images.
Definition:
Texture.h:339
gf::BasicSprite::getTextureRect
const RectF & getTextureRect() const
Get the sub-rectangle of the texture displayed by the sprite.
Definition:
BasicSprite.h:149
gf::Rect< float >
gf
The namespace for gf classes.
Definition:
Action.h:34
gf::BasicSprite::getTexture
const Texture & getTexture() const
Get the source texture of the sprite.
Definition:
BasicSprite.h:101
gf::BasicSprite
Definition:
BasicSprite.h:43
Generated by
1.8.13