YAPOG
0.0.1
Yet Another Pokemon Online Game
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
BaseSprite.cpp
Go to the documentation of this file.
1
#include "
YAPOG/Graphics/Game/Sprite/BaseSprite.hpp
"
2
3
namespace
yap
4
{
5
const
bool
BaseSprite::DEFAULT_VISIBLE_STATE
=
true
;
6
const
sf::Color
BaseSprite::DEFAULT_COLOR
= sf::Color ();
7
8
BaseSprite::BaseSprite
()
9
: spatialInfo_ ()
10
, isVisible_ (DEFAULT_VISIBLE_STATE)
11
, color_ (DEFAULT_COLOR)
12
{
13
}
14
15
BaseSprite::~BaseSprite
()
16
{
17
}
18
19
const
Vector2
&
BaseSprite::GetPosition
()
const
20
{
21
return
spatialInfo_
.
GetPosition
();
22
}
23
24
const
Vector2
&
BaseSprite::GetSize
()
const
25
{
26
spatialInfo_
.
SetSize
(
HandleGetSize
());
27
28
return
spatialInfo_
.
GetSize
();
29
}
30
31
const
Vector2
&
BaseSprite::GetTopLeft
()
const
32
{
33
return
spatialInfo_
.
GetTopLeft
();
34
}
35
36
const
Vector2
&
BaseSprite::GetBottomRight
()
const
37
{
39
GetSize
();
40
41
return
spatialInfo_
.
GetBottomRight
();
42
}
43
44
const
Vector2
&
BaseSprite::GetCenter
()
const
45
{
47
GetSize
();
48
49
return
spatialInfo_
.
GetCenter
();
50
}
51
52
const
sf::FloatRect
&
BaseSprite::GetRectangle
()
const
53
{
55
GetSize
();
56
57
return
spatialInfo_
.
GetRectangle
();
58
}
59
60
void
BaseSprite::Move
(
const
Vector2
& offset)
61
{
62
spatialInfo_
.
SetPosition
(
GetPosition
() + offset);
63
64
HandleMove
(offset);
65
}
66
67
void
BaseSprite::Scale
(
const
Vector2
& factor)
68
{
69
spatialInfo_
.
SetSize
(
70
Vector2
(
71
GetSize
().x * factor.x,
72
GetSize
().y * factor.y));
73
74
HandleScale
(factor);
75
}
76
77
void
BaseSprite::SetPosition
(
const
Vector2
& position)
78
{
79
Move
(position -
GetPosition
());
80
}
81
82
void
BaseSprite::SetSize
(
const
Vector2
& size)
83
{
84
Scale
(
85
Vector2
(
86
size.x /
GetSize
().x,
87
size.y /
GetSize
().y));
88
}
89
90
void
BaseSprite::Draw
(
IDrawingContext
& context)
91
{
92
if
(!
isVisible_
)
93
return
;
94
95
HandleDraw
(context);
96
}
97
98
bool
BaseSprite::IsVisible
()
const
99
{
100
return
isVisible_
;
101
}
102
103
void
BaseSprite::Show
(
bool
isVisible)
104
{
105
isVisible_
= isVisible;
106
107
HandleShow
(isVisible);
108
}
109
110
void
BaseSprite::ChangeColor
(
const
sf::Color& color)
111
{
112
color_
= color;
113
114
HandleChangeColor
(color);
115
}
116
117
void
BaseSprite::Update
(
const
Time
& dt)
118
{
119
HandleUpdate
(dt);
120
}
121
122
BaseSprite::BaseSprite
(
const
BaseSprite
& copy)
123
: spatialInfo_ (copy.spatialInfo_)
124
, isVisible_ (copy.isVisible_)
125
, color_ (copy.color_)
126
{
127
}
128
129
Vector2
BaseSprite::HandleGetSize
()
const
130
{
131
return
spatialInfo_
.
GetSize
();
132
}
133
}
// namespace yap
YAPOG
src
YAPOG
Graphics
Game
Sprite
BaseSprite.cpp
Generated on Mon Sep 17 2012 22:24:25 for YAPOG by
1.8.1.1