APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
The Open Source Physics Project is supported by NSF DUE-0442581.

A game with audio post and replies

Return to the A game with audio thread
Login to post to this thread

How to trigger a sound using audio
Chi-Feng Lin
28 Posts

Dear all

I am making a small game. The game is that some falling apples are caught by a bucket.

My question is how to make a sound when the bucket catches a apple.

Many thanks

Attached File: ejss_src_Unnamed.zip


Replies to How to trigger a sound using audio

Re: How to trigger a sound using audio -
lookang Avatar
lookang
235 Posts

add the following line at this position


function Recordnum () {
  counts = counts +1;
  _view.audio.play(); //lookang
  
}


but the code is not robust enough for 2 very fast apples

but paco or wolfgang can advise on that.

or else it works!
enjoy!

Attached File: ejss_model_Unnamed.zip


OSP@SG blog
OSP@SG Digital Library


Re: Re: How to trigger a sound using audio -
Chi-Feng Lin
28 Posts

Dear lookang

The game has more fun now.

I will try to short the music to improve it.

Thank you.



Deleted Post -
Tom Howard
1 Posts

Post removed on September 26, 2022 at 8:32 AM EST.



Re: Re: How to trigger a sound using audio -
lookang Avatar
lookang
235 Posts

https://iwant2study.org/ospsg/index.php/events/883-20190219-sls-hackathon-etd-cpdd

 

I have a tutorial here that details how to add sound to a game.


OSP@SG blog
OSP@SG Digital Library


OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book