Playing sounds on collision

I need a way to control how many times a sound plays on a collision with another object. When an ice cube lands in a glass in my game, I play a clink sound. I have to limit how many times it plays with a variable in the cube object, otherwise it clinks on and on as collisions fire off as the ice cube settles down.

I'm running into this with other objects, too. Is there a recommended best practice in this regard?

Take a look at the post collision event under the heading "Collision forces" here on this page:

http://developer.anscamobile.com/content/game-edition-collision-detection

I had this same problem in my last game, but instead of ice cubes it was popcorn kernels. I used post collision to register the force and only played the sound when the force was high enough. As the kernels settled into the container the collision forces drop below the threshold and the sound stopped playing. You can play with the checked value until you get the desired result. Hope this is what you are looking for.

Exactly what I'm looking for. Thanks!

views:1492 update:2011/10/15 14:27:43
corona forums © 2003-2011