???
07-05-2007, 11:44 PM
I am trying to get collisions, but IF statements are giving me pain. Only the first 2 work, whichever those are. I've tryed switching them, and I've tried variables, but it doesn't work. Well, here's the mess:
if (pacman.up.hitTest (wall)) {
creatures["Pacman"]["Moving"] = "up";
}
else {
if (pacman.down.hitTest (wall)) {
creatures["Pacman"]["Moving"] = "down";
}
else {
if (pacman.left.hitTest (wall)) {
creatures["Pacman"]["Moving"] = "left";
}
else {
if (pacman.right.hitTest (wall)) {
creatures["Pacman"]["Moving"] = "right";
}
else {
creatures["Pacman"]["Moving"] = "all";
}
}
}
}
I also looked at a thing on switches, but they didn't seem like they would work... Any help?
if (pacman.up.hitTest (wall)) {
creatures["Pacman"]["Moving"] = "up";
}
else {
if (pacman.down.hitTest (wall)) {
creatures["Pacman"]["Moving"] = "down";
}
else {
if (pacman.left.hitTest (wall)) {
creatures["Pacman"]["Moving"] = "left";
}
else {
if (pacman.right.hitTest (wall)) {
creatures["Pacman"]["Moving"] = "right";
}
else {
creatures["Pacman"]["Moving"] = "all";
}
}
}
}
I also looked at a thing on switches, but they didn't seem like they would work... Any help?