I am trying to make a "sweetalert2" box appear when the number of coins in a running game is 20. (I want to let the user know that they have reached 20 coins). If I just used alert, an alert box appears and the game pauses. However, I want to use the sweetalert box for better looks, but even when the box appears, the game still goes on running. How do I stop the game when the sweetalert box appears? The alert function handles this perfectly but it will be too plain for the game. Here is the sweetalert code that I have:
swal({
allowOutsideClick: false,
title: 'You have 20 coins',
html:
'<input id="swal-input1" class="swal2-input">' +
'<input id="swal-input2" class="swal2-input">',
preConfirm: function () {
return new Promise(function (resolve) {
resolve([
$('#swal-input1').val(),
$('#swal-input2').val()
])
})
},
onOpen: function () {
$('#swal-input1').focus()
}
}).then(function (result) {
swal(JSON.stringify(result))
}).catch(swal.noop)