0

我在屏幕顶部制作了 5 个“endzones”,但它们根本没有被检测到。区域被占用后,它被锁定。

safeX() 之类的函数使 xsafe 变量等于 1,因此它们在被占用后将停止工作,但只有最后一行正在跟踪。它们是预先确定的位置,因此它应该可以工作,但它总是跳到最后一个“其他”。我不知道要对这段代码进行什么更改,它可以在程序的其他地方工作,但在这里不行:

if (-5 > man.x && man.x > 25) {
    if (onesafe == 0) {
        safeOne();
        trace("1 done")
    } else {
        deadMan();
        trace("1 full")
    }
} else if (55 > man.x && man.x > 85) {
    if (twosafe == 0) {
        safeTwo();
        trace("2 done")
    } else {
        deadMan();
        trace("2 full")
    }
} else if (115 > man.x && man.x > 145) {
    if (threesafe == 0) {
        safeThree();
        trace("3 done")
    } else {
        deadMan();
        trace("3 full")
    }
} else if (175 > man.x && man.x > 205) {
    if (foursafe == 0) {
        safeFour();
        trace("4 done")
    } else {
        deadMan();
        trace("4 full")
    }
} else if (235 > man.x && man.x > 265) {
    if (fivesafe == 0) {
        safeFive();
        trace("5 done")
    } else {
        deadMan();
        trace("5 full")
    }
} else {
    deadMan();
    trace("last row");
}

这是在动作脚本 3 中

4

1 回答 1

0

它跳到最后else,因为所有条件都不可能。我认为你有一些你的><标志倒退。

例如,在第一个中if,您检查 if-5 > man.x或 ifman.x小于 -5然后检查是否man.x > 25. 此变量不能同时小于 -5 和大于 25。

也许你的意思是if (-5 < man.x && man.x < 25)

写这个的更清晰的方法是if (man.x > -5 && man.x < 25). 当您在比较中将变量放在常量之前时,更容易看到诸如此类的错误。

于 2013-06-22T02:44:33.773 回答