'How to disable code execution until tween complete?
Hi guys i am using Phaser 3.5 and wanted to stop this click function from executing if the tween is still ongoing?
game.input.on("pointerdown", function(pointer) {
game.tweens.add({
targets: playerHands,
angle: 20,
duration: 1000,
yoyo: true
});
});
Thank you
Solution 1:[1]
A flag variable would be something like:
game.canTweenFlag = true;
game.input.on("pointerdown", function(pointer) {
if(game.canTweenFlag) {
game.canTweenFlag = false;
game.tweens.add({
targets: playerHands,
angle: 20,
duration: 1000,
yoyo: true,
onComplete: function () { game.canTweenFlag = true; }
});
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Molly J |
