ask
Ask the player a ‘yes’ or ‘no’ question which answered with the A or B button.
game.ask("")
You ask a question which the player answers by pressing either the A or B button. If the player presses A, a true
condition results. If the B button is pressed, the condition is false
. You can include an optional subtitle as a second part of your question.
Parameters
- title: a string that has the text of your question.
- subtitle: a string that is an optional second part of your question.
Returns
- a boolean value that is
true
if the player pressed A in response to your question andfalse
if the player pressed B.
Example
Ask the player if they’re ready to play the next game level. If so, set the score to 0
. Otherwise, finish the game.
if (game.ask("Ready to play?", "Next: advanced level")) {
info.setScore(0)
} else {
game.over()
}