Making Sprite Visible Upon Click

Screenshot 2022-05-06 3.02.17 PM

**What I expect to happen: The student wants the love sprite to appear when he/user presses the space key.
**What actually happens: The love sprite appears with all code at the beginning
**What I’ve tried: taking the love sprite out of the loop and placed it on top of the code, played with the keyDown command, added else statement to project.

Hi @sbowman,

So, the love sprite is appearing when you hit run because the if statement is running one time instantly but then program returns to run the draw function. The program does not check that the space key is down because the if statement is not in the draw loop.

When you do move the if statement to the draw loop, you do not need the nested if statement or keyDown variable. You only need the first if statement. The first if statement reads: if keyDown(“space”) is same as if the space key is being pressed therefore is true then…do this …else if it is not being pressed do something else. Try removing the keyDown variable and solving with only one if statement:)
~Michelle

Another thing that is wrong is that the love sprite is already visible visible, due to its coordinates, and no extra code making it invisible. Try adding love.visible = false, then when space is pressed, love.visible = true. Also, move the if statement into the draw loop, so it keeps checking for it.