Javascript 如果你已经赢了或输了,如何停止计分?
如果我点击红色的,它就会得分。如果我点击红球,即使在得分或失分后,它仍然有效。那么,在特定的数字之后,如何停止计数呢Javascript 如果你已经赢了或输了,如何停止计分?,javascript,Javascript,如果我点击红色的,它就会得分。如果我点击红球,即使在得分或失分后,它仍然有效。那么,在特定的数字之后,如何停止计数呢 我认为这可能是你的解决方案: function clickHandler(e) { var elem= getElementAt(e.getX(), e.getY()); if(score !=0) { if(elem != null && elem.getColor() == Color.red) { score++;
我认为这可能是你的解决方案:
function clickHandler(e) {
var elem= getElementAt(e.getX(), e.getY());
if(score !=0)
{
if(elem != null && elem.getColor() == Color.red)
{
score++;
} else {
score--;
}
}
设置一个布尔值,然后在if语句中使用它
if (isPlaying && ...otherConditions) {
your code to change score here
}