Welcome,
Guest
. Please
login
or
register
. Did you miss your
activation email?
French forum
Home
Help
Search
Login
Register
SFML community forums
»
Help
»
General
»
Need help with deleting Numbers (INT)!
Print
Pages: [
1
]
Author
Topic: Need help with deleting Numbers (INT)! (Read 1103 times)
0 Members and 1 Guest are viewing this topic.
antton
Newbie
Posts: 3
Need help with deleting Numbers (INT)!
«
on:
December 18, 2016, 05:01:24 pm »
Hello guys!
have received a obstacle when I have worked with my game. When i have over 10 reps I can buy a item and it will cost me 10 reps. The problem is when if i get over 20 reps and buy the item it will take away 20 reps but actually it should only cost 10?!.
this is the code Underneath
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
{
if (this->score->reps >= 10)
{
this->stats->Strength += 1;
this->score->reps -= 10;
}
}
Pleas someone can help me with this question!
Logged
Laurent
Administrator
Hero Member
Posts: 32498
Re: Need help with deleting Numbers (INT)!
«
Reply #1 on:
December 18, 2016, 08:10:48 pm »
sf::Mouse::isButtonPressed
is true as long as you press the button. So even if i only lasts a few milliseconds, it's enough to trigger your condition several times.
You should use the MouseButtonPressed event instead.
Logged
Laurent Gomila - SFML developer
Print
Pages: [
1
]
SFML community forums
»
Help
»
General
»
Need help with deleting Numbers (INT)!
anything