play sound while body is in motion

  ... the Physics Box2D Extension for AndEngine.

play sound while body is in motion

Postby jdwieber » Wed Feb 22, 2012 4:18 am

Hello,

I want to play a sound for as long as a body stays in motion, and stop it when the body comes to rest. Is there a way to determine when a body comes to rest? I didn't see a place to register callbacks. Thanks.
jdwieber
 
Posts: 6
Joined: Tue Feb 21, 2012 3:02 am

Re: play sound while body is in motion

Postby RealMayo » Wed Feb 22, 2012 5:49 pm

All I can think of is for you to use an UpdateHandler that constantly probes "getLinearVelocity" of the body, and once that velocity equals zero, then stop the sound.
User avatar
RealMayo
 
Posts: 1683
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL

Re: play sound while body is in motion

Postby jdwieber » Wed Feb 22, 2012 6:46 pm

Hi RealMayo,

Thanks for the reply. Unfortunately, that's the best I can come up with too. The only thing is that I use isAwake on my body objects. That way I don't have to worry about thresholds that bullet already calculates for me.
jdwieber
 
Posts: 6
Joined: Tue Feb 21, 2012 3:02 am


Return to Physics Box2D

Who is online

Users browsing this forum: No registered users and 9 guests