Quote:
Originally Posted by ekat90
I'm trying to make a penguin game, where when I've controlled the penguin so that when the penguin is close enough to a fish, its commanded to say yum and for the fish dissapear, thats all fine but my only dillemma is even though I make the fish dissapear when I run the penguin over the invisible fish the penguin still says yum!. This is really really frustrating me and no matter what i read or do I cannot make the penguin only say it once, after its eaten it! please I'd appreciate any help.
|
Resolving this problem is quite simple by using an if statement to check if the fish has been eaten or not.
To do this, you'll want to create a boolean that checks if the fish is showing or not.
Code:
boolean fishDead()
{
if (fish.isShowing == true)
{
return true;
}
return false;
}
Next, all you'll need to do is check if the fish is dead or not before executing the code where the fish says "yum!".
To do this, simply add the following if statement:
Code:
if (fishDead() == true)
{
//say("Yum");
}
Simple as that!
Good luck (: