0
我试图让pacman陷入幽灵时失去了生命。然后根据他的生活数量他显示了一个特定的信息,但是这个变量似乎并没有考虑到我正在改变它。在javascript中修改变量?不工作
ANy suggestions?
var life=3;
// Lorsque l'on rencontre un fantome.
function manchePerdue()
{
x_Pacman = 13;
y_Pacman = 10;
life = life-1;
if (life=2) {
window.alert("2 Lives Left");
}
else if (life=1) {
window.alert("1 Life Left");
}
else {
window.alert("Game Over");
gameover();
}
}
'='是赋值'=='是否相等,请检查你的if语句。 – hoss