PDA

Click to See Complete Forum and Search --> : Action Script Help


Neballer
12-07-2005, 12:04 AM
Alright, I'm currently designing a game for one of my final projects and I've almost got it nailed down except for this code.
swf file (http://www.rgsdesign.com/carp/redlazer.swf)

for (i=1; i<=_root.count; i++) {
if (this.hitTest(_root["bt"+i])) {
_root.score += 100;
_root["bt"+i].gotoAndStop(2);
this.removeMovieClip();
}
}
This checks the hit test between the enemy ship and the lazer. It works fine, but it slows the swf way down because it is constantly checking to see if there is a hit test from 0 - ∞. I want it to check for a hit test with only the lazers on the stage. I know there is a way to do this, but don't know the code for it.

Any help would be fantastic, because after I fix that, it's pretty much down.

embersyc
12-07-2005, 03:51 AM
Hard to say only seeing this bit of code... how are you calling this?

Is it in a function that is called when the lazer enters the stage?

Doesn't seem to be a lot of actionscript help on this forum, and I'm certainly no expert.

Neballer
12-07-2005, 04:07 AM
this is how I'm calling it:
_root.onMouseDown = function() {
lazerCounter++;
_root.lazer.duplicateMovieClip("lazer"+lazerCounter, lazerCounter);
_root["lazer"+lazerCounter]._visible = true;
};

embersyc
12-07-2005, 04:58 PM
Hmm, affraid I can't really be of much help unfortunately.

You might want to ask over at actionscript.org

Neballer
12-07-2005, 05:03 PM
thanks