The more I work on this, the more baffled I become - I've been programming for
20+ years, and I'm not sure I like actionscript at all. It seems to ignore "if"
statements at will, and as best I can tell, program flow doesn't neccessarily
go to the exact frame it is sent to! It even seems that it arbitrarily adds
numbers when told to subtract!! Am I missing something really basic here, or is
this an extremely flakey language!!??
Here is the latest code in frame 3 of the motionSphere_mc object:
setProperty("", _x, Number(getProperty("", _x))+Number(xStep));
if (_root.ship.hitTest(this)) {
if (!collision) {
if (numHits<10) {
numHits = numHits+1;
with (_root.ship) {
gotoAndPlay(2);
}
} else {
with (_root.ship) {
gotoAndPlay(5);
}
livesLeft = livesLeft-1;
_root.lifeScore = livesLeft;
if (livesLeft<5) {
setProperty("_root.life1", _visible, false);
}
if (livesLeft<4) {
setProperty("_root.life2", _visible, false);
}
if (livesLeft<3) {
setProperty("_root.life3", _visible, false);
}
if (livesLeft<2) {
setProperty("_root.life4", _visible, false);
}
if (livesLeft==0) {
gotoAndPlay("gameOver");
}
numHits = 0;
}
collision = true;
} else {
collision = false;
}
}
END OF CODE
Given this code, and the code from frames 1, 2, and 4 (see previous post
above) why in the world would the livesLeft variable turn around halfway
through play and start adding to the variable instead of subtracting, then turn
around again and decrement as it should? Then, when it DOES finally reach a
value of "0", the "if" statement :
if (livesLeft==0)
seems to be flatly ignored.
I've uploded the game to my website
-
http://www.cjreynolds.com/robertfogt/roids.fla to download the source.
Thanks,
joe