Skip to main content
Inspiring
November 1, 2006
Question

hittest on a masked object?

  • November 1, 2006
  • 1 reply
  • 269 views
Hi

I am developing a game, which has heads that popup at random from behind two
hills. the user throws snowballs at the heads. I am using the hittest
function to test for the collison. the problem i m having is when the heads
are hidden, the hittest is still coming back as true if the snowball hits
the area where the head is hidden. does anyone have any suggestions?

you can see the current version i m having problems with -
http://www.wiredmonkey.co.uk/snowball

Thanks in advance

Shaun


This topic has been closed for replies.

1 reply

Participating Frequently
November 1, 2006
I have 2 ideas for you. Not sure how easy they would be to implement in to your current coding.

1) Use a flag variable that you would set to "true" if the head was visible and "false" when not. Then when using the hitTest() method you could also test to see if the variable was also "true". If it was then it was a hit if not then nothing.

2) If your mask is a movieclip, the use the hitTest method on the snowball and the head and also on the head and the mask. If they both came back "true" then it would be a hit, otherwise not.


Tim