Skip to main content
Apr 14, 2006 2:43 PM UTC
Answered

hitTest issues

Ive started writing the 'hitTest' code for the game, i wasnt sure how, since i hadnt' tried it before- but after a short tutorial it's simple enough. However, i am running into problems.

Currently, my stage is set up with a ship, that fires bullets, at the top of the stage, i have a long movie clip that will act as a 'wall', when the bullets collide with the wall they should stop moving, and 'blow up'. I have my animations, and all the fun stuff down- but my hit test isnt working one bit!

here is the code for the hit test- it runs in my main _root enterframe loop.

thanks.
This topic is closed to new replies. Start a new post to keep the conversation going.
kglad
kgladCorrect answer
Community Expert
Apr 18, 2006 2:43 PM UTC
you're creating 10 bullets but you're only checking a hitTest on 5 of them. that's a problem.

p.s. you don't need to remove your bullet movieclips because you're removing them when you reuse their depths during their creation.

17 replies

kglad
Community Expert
Community Expert
Apr 19, 2006 1:17 AM UTC
you're welcome.
Translate
Apr 18, 2006 2:50 PM UTC
kglad- thats a huge improvement- thanks so much.
Translate
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
Apr 18, 2006 2:43 PM UTC
you're creating 10 bullets but you're only checking a hitTest on 5 of them. that's a problem.

p.s. you don't need to remove your bullet movieclips because you're removing them when you reuse their depths during their creation.
Translate
Apr 18, 2006 2:37 PM UTC
'thanks
Translate
kglad
Community Expert
Community Expert
Apr 18, 2006 2:31 PM UTC
i have the file. you can remove it.
Translate
Apr 18, 2006 2:21 PM UTC
kglad,
i totaly understand - im sorry to hear that. I will post the file up- i dont think much will happen from the issue of showing it- i will just pull it off my server after you retrieve the file.

-edit-
Translate
kglad
Community Expert
Community Expert
Apr 18, 2006 2:08 PM UTC
no, i've had too many problems with forum users taking advantage of that situation using me as their personal flash editor and loading my mailbox with fla files that need editing.

if you can extract just the code and graphics that display the problem and post a link to that fla, that would work, too.
Translate
kglad
Community Expert
Community Expert
Apr 18, 2006 2:43 AM UTC
post a link to your fla that displays the problem.
Translate
Apr 18, 2006 1:29 PM UTC
KGlad,
Is there a way i can privately send you the link- this is for a corporate customer, and i cannot afford to throw the .fla around on a public message board.

thanks so much.
Translate
kglad
Community Expert
Community Expert
Apr 17, 2006 2:35 PM UTC
you're welcome.
Translate
Apr 17, 2006 2:51 PM UTC
My only problem- it seems as if half the bullets collide- and the others dont. It seems like the first few of the cycle will collide, but rest skip right past- im wondering if this has to do with the depth of 'tWall' and 'bullet"

-edit-

Ive swapped depth's for my tWall- this doesnt do anything. Ive also slowed the bullets again to see what was happening- I counted out of 11bullets that passed the wall- 3 collided, the rest passed through easily.
Translate
Apr 17, 2006 1:28 PM UTC
--EDIT--
I slowed the bullet speed to test- and it worked perfectly. Thanks!

this is code that i had borrowed from a existing tutorial- and modified to fit my game for the 'wall' collision.

var bulleti = 6;
while (--bulleti>0) {
if (_root.tWall.hitTest(eval("_root.bullet"+bulleti))) {
eval("_root.bullet"+bulleti).gotoAndPlay(2);
trace("hit");
}
}
Translate