hitTest problem

Hi there,

I have a ball rotating in a circle. It passes symbols and this triggers a sound. The sound is a short percussive sound. I am using the standard hitTest code

if (this.hitTest(“symbolName”)){

It seems to work to an extent.

The problem is that because the ball is smaller than the symbols, the sound is triggered several times as it passes over them. I only want the sound to trigger once (preferrably when it meets the centre of the symbol).

Can I set the point of collision? Or is my only option to make the sound longer so once it plays it won’t play again until ball has passed outside the symbol?

Any ideas?

Cheers!

Try setting a variable to true once it hits, and only play the sound once its false AND hits. When it isnt hitting, set the variable to false. Something like this (untested):

if(hitTest stuff here){
   if(!alreadyHit){
   play sound
   alreadyHit = true;
   }
} else {
   alreadyHit = false;
}