I had made an integer named lifePoints then I set an If statement to CHANGE the integer's value from 100 to 90 how
int lifePoints = 100;
// not a full code but just giving an explanation
if (player == ("attackthem!"))
{
change integer value here. how?
}
I searched google and it came out changing String to integer.
{
lifePoints -= 10;
}
which corresponds to
{
lifePoints = lifePoints - 10;
}
If you want to set it to 90
, then:
lifePoints = 90;
If you want to substract 10
, then:
lifePoints -= 10;
OR: lifePoints = lifePoints - 10;
int lifePoints = 100;
// not a full code but just giving an explanation
if (player == ("attackthem!"))
{
lifePoints = 90; //CHANGE the integer's value from 100 to 90
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.