This content has been marked as final. Show 5 replies
> i was wondering if there was a way to do hit detection
> without the on enterframe clip event.
Absolutely. You may invoke the MovieClip.hitTest() method whenever you
like. It could be an onEnterFrame even, a mouse click, a timer, just
> This is because if there are alot of things that need to be
> checked it could get a bit laggy.
If you've got to check a lot of things, you've got to check 'em. If you
must check repeatedly, then it doesn't much matter if you use an
onEnterFrame event or, say, a setInterval() loop. If you know the position
and surface area of your movie clip, you can certainly perform "imaginary"
hit tests against those coordinates. That would probably be more efficient
because it would omit a method call.
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."
you can trigger a hitTest() any number of ways. however, if you have no idea when a positive (or negative) hitTest() will occur, then you must use an continual loop of some kind.
This is an interesting question
What is your context?
"ahref" <firstname.lastname@example.org> wrote in message
> hi there,
> i was wondering if there was a way to do hit detection without the on
> enterframe clip event. This is because if there are alot of things that
> be checked it could get a bit laggy.
well i am making a space exploration game. Much like the game Star control 2. in such a game there are alot of things that will need checking on a solar system screen;
planet with ship
space station with ship
enemy ship with planet
enemy ship with ship
ship with edge of solar system(leads to hyperspace)
and probably more i havent thought of.
in particulary busy solar systems there is a lot tocheck and i thought this may get laggy.
because you don't know when collisions will occur, use a continual loop like setInterval() or onEnterFrame. you only need one loop to check all collisions.