481
General / Problem with compiling AniSprite
« on: January 08, 2012, 06:36:43 pm »
You are probably missing a lib file.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
while(Window.IsOpened())
{
if( up )
{
if (Clock.GetElapsedTime() >= 1000)
{
++Time;
Clock.Reset();
}
}
else
{
if (Clock.GetElapsedTime() >= 1000)
{
--Time;
Clock.Reset();
}
}
if( Time >= 170 )
up = false;
if( Time <= 0 )
up = true;
}
if (up)
{
if (Clock.GetElapsedTime() > 25)
{
++Time;
Clock.Reset();
}
}
sf::Clock Clock;
int Time = 0;
while (...)
{
if (up)
{
Time += Clock.GetElapsedTime();
Clock.Reset();
}
else
{
Time -= Clock.GetElapsedTime()
Clock.Reset();
}
}
functions and public variables use the camelCase notation
sf::Text text(" test ");
float Width = text.GetGlobalBounds().Width;
void Draw(sf::RenderTarget& target, sf::RenderStates states) const
{
SetScale(4, 4);
}
Object obj;
obj.Scale(2, 2);
window.Draw(obj);
void Object::Render(sf::RenderTarget& target, sf::Renderer& renderer) const
{
// I want to change the scale here!
SetScale(4, 4);
}
size_t CharacterSize = Text.GetCharacterSize();
sf::Font Font = Text.GetFont();
std::string String = Text.GetString().ToAnsiString();
bool bold = (Text.GetStyle() & sf::Text::Bold);
size_t MaxHeight = 0;
for (size_t x=0; x<Text.GetString().GetSize(); ++x)
{
sf::Uint32 Character = String.at(x);
const sf::Glyph& CurrentGlyph = Font.GetGlyph(Character, CharacterSize, bold);
size_t Height = CurrentGlyph.Bounds.Height;
if (MaxHeight < Height)
MaxHeight = Height;
}
sf::FloatRect rect = Text.GetRect();
rect.Left = (TextureNormal.GetWidth() / 2.0f) - (rect.Width / 2.0f);
rect.Top = (TextureNormal.GetHeight() / 2.0f) - (MaxHeight/2.0f) - (rect.Height-MaxHeight) + ((rect.Height-CharacterSize)/2.0f);
Text.SetPosition(rect.Left, rect.Top);