I was going through the Quiz App video and noticed a small issue. When you click the correct answer I noticed I could still click the button multiple times until the next question appears and this obviously increases the score.
How do I block the click feature on a button for few seconds before the next question is displayed.
Buttons have a property called âDisabledâ which stops them from responding to being clicked.
When an answer is selected, you could disable all of the Buttons on your Screen by setting âDisabledâ to true. When the next question is loaded, you can enable all of the Buttons again by setting 'Disabled to false
If you want to keep the appearance of the Button intact, you could use a Boolean: a variable whose only possible values are true or false.
You can initialize an app variable answerNotSelected to true.
When the user has selected an answer, set answerNotSelected to false.
When a new question opens, set answerNotSelected to true again.
Then just put whatever blocks you have for your Buttons inside an if block that says âif answerNotSelectedâ.
This will disable the effects of your Button once an answer has been selected without changing its appearance.
Block view of what you need to do based on @jane reply:
First initialize a variable and set it to FALSE. I called mine âanswerSelectedâ. This means I have not clicked on any answer button, so everything is normal.
Next on button click block, add an if statement and check if the variable is still false. If FALSE, then everything inside the block will take immediate effect
Immediately after the IF statement, add set variable block to TRUE. This would ensure that if you try to click the button immediately while the answer is been processed, nothing will happen to the button
Lastly you need to set the variable back to FALSE so we can click on buttons again. Add this at end of the âUpdate quiz for each questionâ block
Hope this helps visually.
The next bit I need to figure out is when I exit question halfway and come back to it, I want it to restart question from beginning and not from where I last was.
So when I click on YES, it takes me to Home Screen
Click on No, it takes me back to game screen
The issue with Home Screen which is also my Menu screen with a Play button which goes to game screen, is when I click Play, it takes me to game screen but continues from last question before I exited rather than restarting questions from 1
No it didnât work as expected. When I click Yes, it resets question back to question 1 but then the score at first resets to 0 but then changes to last score