Skip to content

Commit ff25713

Browse files
committed
Fixed bug in centerOrigin()
1 parent cc8d911 commit ff25713

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

05_States/Source/Utility.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
void centerOrigin(sf::Sprite& sprite)
88
{
99
sf::FloatRect bounds = sprite.getLocalBounds();
10-
sprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);
10+
sprite.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
1111
}
1212

1313
void centerOrigin(sf::Text& text)
1414
{
1515
sf::FloatRect bounds = text.getLocalBounds();
16-
text.setOrigin(bounds.width / 2.f, bounds.height / 2.f);
16+
text.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
1717
}

06_Menus/Source/Utility.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ std::string toString(sf::Keyboard::Key key)
122122
void centerOrigin(sf::Sprite& sprite)
123123
{
124124
sf::FloatRect bounds = sprite.getLocalBounds();
125-
sprite.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
125+
sprite.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
126126
}
127127

128128
void centerOrigin(sf::Text& text)
129129
{
130130
sf::FloatRect bounds = text.getLocalBounds();
131-
text.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
131+
text.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
132132
}

07_Gameplay/Source/Utility.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ std::string toString(sf::Keyboard::Key key)
136136
void centerOrigin(sf::Sprite& sprite)
137137
{
138138
sf::FloatRect bounds = sprite.getLocalBounds();
139-
sprite.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
139+
sprite.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
140140
}
141141

142142
void centerOrigin(sf::Text& text)
143143
{
144144
sf::FloatRect bounds = text.getLocalBounds();
145-
text.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
145+
text.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
146146
}
147147

148148
float toDegree(float radian)

08_Graphics/Source/Utility.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,19 @@ std::string toString(sf::Keyboard::Key key)
137137
void centerOrigin(sf::Sprite& sprite)
138138
{
139139
sf::FloatRect bounds = sprite.getLocalBounds();
140-
sprite.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
140+
sprite.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
141141
}
142142

143143
void centerOrigin(sf::Text& text)
144144
{
145145
sf::FloatRect bounds = text.getLocalBounds();
146-
text.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
146+
text.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
147147
}
148148

149149
void centerOrigin(Animation& animation)
150150
{
151151
sf::FloatRect bounds = animation.getLocalBounds();
152-
animation.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
152+
animation.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
153153
}
154154

155155
float toDegree(float radian)

09_Audio/Source/Utility.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,19 @@ std::string toString(sf::Keyboard::Key key)
137137
void centerOrigin(sf::Sprite& sprite)
138138
{
139139
sf::FloatRect bounds = sprite.getLocalBounds();
140-
sprite.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
140+
sprite.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
141141
}
142142

143143
void centerOrigin(sf::Text& text)
144144
{
145145
sf::FloatRect bounds = text.getLocalBounds();
146-
text.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
146+
text.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
147147
}
148148

149149
void centerOrigin(Animation& animation)
150150
{
151151
sf::FloatRect bounds = animation.getLocalBounds();
152-
animation.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
152+
animation.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
153153
}
154154

155155
float toDegree(float radian)

10_Network/Source/Utility.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,19 @@ std::string toString(sf::Keyboard::Key key)
137137
void centerOrigin(sf::Sprite& sprite)
138138
{
139139
sf::FloatRect bounds = sprite.getLocalBounds();
140-
sprite.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
140+
sprite.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
141141
}
142142

143143
void centerOrigin(sf::Text& text)
144144
{
145145
sf::FloatRect bounds = text.getLocalBounds();
146-
text.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
146+
text.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
147147
}
148148

149149
void centerOrigin(Animation& animation)
150150
{
151151
sf::FloatRect bounds = animation.getLocalBounds();
152-
animation.setOrigin(std::floor(bounds.width / 2.f), std::floor(bounds.height / 2.f));
152+
animation.setOrigin(std::floor(bounds.left + bounds.width / 2.f), std::floor(bounds.top + bounds.height / 2.f));
153153
}
154154

155155
float toDegree(float radian)

0 commit comments

Comments
 (0)