1
General / Dialogue-Box | Game-Developement with SFML
« on: February 23, 2017, 04:29:59 pm »
Hello,
I have a problem. I am trying to write a function that creates a Dialogue Box for my Game. When the time is bigger than 4s, the player should be able to press the Spacebar and a new Text appears. But when I press the spacebar, the second updateText appears. What I´m doing wrong? I call the function in the main Game Loop.
I´m a beginner in creating Games with SFML - so don´t be to strict with me .
Here is my code:
void updateText(String UpdateText, int x, int y, int size, String UpdateText2, int x2, int y2, int size2)
{
Time elapsed1 = clock1.restart();
tempClock1 += elapsed1;
if (tempClock1.asSeconds() > 4)
{
if (Keyboard::isKeyPressed(Keyboard::Space))
{
MessageBox_text.setString(UpdateText);
MessageBox_text.setPosition(x, y);
MessageBox_text.setCharacterSize(size);
Time elapsed2 = clock2.restart();
tempClock2 += elapsed2;
if (tempClock2.asSeconds() > 4)
{
if (Keyboard::isKeyPressed(Keyboard::Space))
{
MessageBox_text.setString(UpdateText2);
MessageBox_text.setPosition(x2, y2);
MessageBox_text.setCharacterSize(size2);
}
}
}
}
}
I have a problem. I am trying to write a function that creates a Dialogue Box for my Game. When the time is bigger than 4s, the player should be able to press the Spacebar and a new Text appears. But when I press the spacebar, the second updateText appears. What I´m doing wrong? I call the function in the main Game Loop.
I´m a beginner in creating Games with SFML - so don´t be to strict with me .
Here is my code:
void updateText(String UpdateText, int x, int y, int size, String UpdateText2, int x2, int y2, int size2)
{
Time elapsed1 = clock1.restart();
tempClock1 += elapsed1;
if (tempClock1.asSeconds() > 4)
{
if (Keyboard::isKeyPressed(Keyboard::Space))
{
MessageBox_text.setString(UpdateText);
MessageBox_text.setPosition(x, y);
MessageBox_text.setCharacterSize(size);
Time elapsed2 = clock2.restart();
tempClock2 += elapsed2;
if (tempClock2.asSeconds() > 4)
{
if (Keyboard::isKeyPressed(Keyboard::Space))
{
MessageBox_text.setString(UpdateText2);
MessageBox_text.setPosition(x2, y2);
MessageBox_text.setCharacterSize(size2);
}
}
}
}
}