There are loads of places to get hold of free samples and loads of samples on offer, or you can create your own.
While looking for effects for this project, I came across the perfect one. Unfortunately, there is nowhere to upload the file here, So here's the link to where I got it;
http://www.grsites.com/archive/sounds/category/4/?offset=228
The sound is titled Drawer opening or misc235.wav, it is 16.6 kb and is in the miscellaneous section.
Download the WAV version to your project media folder and call it "panel.wav"
This plays for around 1.5 seconds, so we need to make a slight change to the timing of our open routine.
panelSpeed# = panelHeight# / (lastFPS# * 1.25)
This changes the time taken from 1 second to 1.25 seconds. The value that lastFPS# is multiplied by represents the number of seconds taken.
Although the sound plays for slightly longer, it includes a part which represents the panel clicking into place which accounts for the difference.
The sound is loaded using the loadSound() command, and as always, returns a reference to the sound loaded, which we store in a variable. Loading is done at the start of the program after the panel objects are created.
panelSound = loadSound("panel.wav")
To play the sound, we use the command playSound() at the point where the panelOpen variable is changed
playSound( panelSound )
Here is a part of the program showing the location of the new lines.
And that's it. Compile and run the program to see the effect.
No comments:
Post a Comment