[英]Mouseover with three attempts
I have this code: 我有以下代码:
mug.addEventListener('mouseover', function () {
if (//I don't know what to put in here..) {
console.log('game over');
}
}
And I basically want it to say that when the user has hovered three times over an image the game is over. 我基本上要说的是,当用户将鼠标悬停在图像上三遍时,游戏就结束了。
Thanks! 谢谢!
It's very simple to do: 这很简单:
var mouseOverCount = 0;
mug.addEventListener('mouseover', function () {
if (mouseOverCount >= 2) {
console.log('game over');
}
mouseOverCount++;
});
I suggest you to read (or watch) some beginner programming tutorials, so you will understand basic concepts. 我建议您阅读(或观看)一些初学者编程教程,以便您了解基本概念。 You can find a lot of them in the internet.
您可以在互联网上找到很多。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.