AS'd movement, and repeat, Part 2

I’m working on a Stick Shooting game (the first draft can be seen at http://www.stickslaughter.com/stickshooter.html) and had been attempting to make a stick, walk from one side of the stage to the other, and repeat. I can do that easily now with Lostinbetas help.

But… I’ve run into one more problem, I’m trying to make an escape count (how many sticks you missed, but when I put the actionscript on the stick, even after you shoot it, it still counts as escaped…

Here’s the code that’s on the stick:


onClipEvent (enterFrame) {
    speed = 10;
    this._x += speed;
    if (this._x>=500) {
        this._x = 20;
        this.gotoAndPlay(1);
_root.escaped = _root.escaped + 1;

}

Okay, so that’s adds one to the escaped count, when the stick has reached 500 x on the stage. How would I make it so when you shoot the stick, and he fades down to 0 alpha, that it doesn’t count on the escape count?

Thanks in advance,
KoRRupt

hmm… why dont you try doing _this.unload() ? and then duplicating the movie… cause I’m not quite sure what’s wrong with your code - it seems ok.

arghhhh

I can’t seem to figure it out :q:

Looking towards lostinbeta for some help

onClipEvent (enterFrame) {
    speed = 10;
    this._x += speed;
    if (this._x>=500) {
        this._x = 20;
        this.gotoAndPlay(1);
        _root.escaped++

}

You can increment esaped with ++ instead of what you were doing before… it basically does the same exact thing you were doing before, but written smaller…lol.

As for the problem at hand… you increment the escape when the clip reaches the end.

Now considering your last problem… your clip, even after being shot still moved until it hit the 500 mark, so of course it will always increment.

So what you will have to do is add another if statement to see if the out animation has been played, the easiest way probably for this is to take the frame number that your fade out animation starts (after it is clicked) and check to see if that frame or higher is being played, then increment. Something like…

onClipEvent (enterFrame) {
	speed = 10;
	this._x += speed;
	if (this._x>=500) {
		if (this._currentframe>=frameNumberThatStartsDeathAnimation) {
			_root.escaped++;
		}
		this._x = 20;
		this.gotoAndPlay(1);
	}
}

Dude, are you like a frickin super genious. Everything you explain to me works everytime!!! Hahaha, thanks again man.

Thanks!
-KoRRupt

LOL… super genius… nah, but glad I could get it to work for you :slight_smile:

Thank again man,
KoRRupt