图像显示是否满足条件

Image shows if condition is met

我正在制作一个饼干唱首歌式的游戏,我正在制作一个升级栏。一个图标开始不可见,一旦你有 1 个光标,它就会变得可见。问题是它不是。

我已经仔细查看了,仍然找不到错误。 这是在 JSFiddle 中。 在这里-https://jsfiddle.net/wizviper/mq0qwnvr/ 主要代码-

document.getElementById("reinforcedFingerShop").addEventListener(cursorAmount >= 1, function() {

if (reinforcedFingerActive = 0) {

  $(this).show();

}

  });

我认为问题出在:

if (reinforcedFingerActive = 0) {

也许你忘记了第二个 =

阅读官方 MDN addEventListener 文档,了解如何使用此功能。第一个参数是 type

A string representing the event type to listen for.

在您的代码中,您的第一个参数是 cursorAmount >= 1

addEventListener 监听事件,但您正在为其分配条件 "cursorAmount >= 1"。 我猜你可能想知道什么时候(cursorAmount >= 1)和什么时候(reinforcedFingerActive == 0),请提供你的代码的相关部分,以便我们更好地帮助你

更新

您正在 "cursorShop" 函数内更改 cursorAmount,因此检查 "reinforcedFingerActive == 0" 条件的最佳位置就在那里。

document.getElementById("cursorShop").onclick = function() {
    if (cookies >= cursorPrice) {
      cookies = cookies - cursorPrice;
      cursorPrice = cursorPrice * 1.15;
      cps = cps + 0.1;
      updateValue();
      cursorAmount = cursorAmount + 1;
      if (reinforcedFingerActive == 0) {
        $(this).show();
      }
    }
  }

我没有测试过,但应该可以。