-------------------------------------------------------------------------------- -- Handler.......... : onEnterFrame -- Author........... : -- Description...... : -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- function PunctualSound_Ball.onEnterFrame ( ) -------------------------------------------------------------------------------- -- Get the object linked to the AI -- local o = this.getObject ( ) -- Update average speed -- local avgSpeed = 0.5 * ( this.nAverageSpeed ( ) + dynamics.getLinearSpeed ( o ) ) this.nAverageSpeed ( avgSpeed ) -- If touching the ground, play a sound -- if ( dynamics.getLastCollisionTime ( o ) < 0.1 and avgSpeed > 2 ) then sound.play ( o, 0, 1, false, 0.5 ) end -------------------------------------------------------------------------------- end --------------------------------------------------------------------------------