Skip to main content
April 14, 2006
Answered

hitTest issues

  • April 14, 2006
  • 17 replies
  • 913 views
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.
Correct answer kglad
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
April 15, 2006
do you have movieclips on the _root timeline with instance (not library) names of tWall, bullet1, bullet2, bullet3, ...,bullet5?

are heights of your bullets and tWall sufficient that changing the _y property of the bullets by 30 at each increment would not cause the bullets to jump over tWall and fail to make contact?
April 17, 2006
kglad,
skipping over the wall, ill have to check that- i never even thought about that.

Everything is named properly- i have 'bullet' on my timeline- witch gets attached 'i' at the end, so they should be named correctly. and tWall is named correctly.
April 14, 2006
Hrm- id doesnt collide with anything..
kglad
Community Expert
Community Expert
April 14, 2006
is that code in a loop?
April 14, 2006
Kglad, yes- i will post up the entire frame of code