Page 1 of 1

audio and sound effects

Posted: Fri Jun 08, 2012 9:57 am
by prexsoccer
sorry im totally new in this livecode.
im going to develop a game and i want to add sound effects on it like when the player punch an enemy.

anyone has an Idea about this? please share.
thank you.

best regard,
prex :)

Re: audio and sound effects

Posted: Fri Jun 08, 2012 1:58 pm
by Klaus
Hi prex,

1. welcome to the forum! :)

2. check these stacks:
http://www.runrev.com/developers/lesson ... nferences/

3. regarding your question:
basically you just play a sound (file) at the right time, but you might need to be a TAD more specific about your question. 8)


Best

Klaus

Re: audio and sound effects

Posted: Sat Jun 09, 2012 3:29 am
by prexsoccer
hi klaus,

thank you for the link that you provide,
If so happen that you have a sample script that would trigger a certain music

like:

on mouseUp
if player is jump then
play jump audio
else if player is running then
play running audio
end if
end mouseUp

hopefully I get your point and you get my point :)

thank you much :)

Re: audio and sound effects

Posted: Sat Jun 09, 2012 4:17 pm
by Klaus
Hi prex,

OK, given that "tPlayer" (player is a reserved word in LiveCode!) is the name of a variable
and you want to check its content and act accordingly:

Code: Select all

...
if tPlayer = "jump" then
  play audioclip "jump.aif"
     else if tPlayer = "running" then

  ## audioclip can be abbreviated to ac
  play ac "running.aif"
end if
...
8)

Best

Klaus

Re: audio and sound effects

Posted: Mon Jun 11, 2012 4:32 am
by prexsoccer
thank you klaus.

but one more thing. does it support mp3,mp4,mov files?

thank you for this sample code it solves my problem :)

Re: audio and sound effects

Posted: Mon Jun 11, 2012 11:46 am
by Klaus
Hi prex,

the "play" command will only play uncompressed AIF and WAV and compressed AU sounds on hte desktop.
For MP3 etc. you need to use a "player" object.

Check the "Images and Multimedia" stack here:
http://www.runrev.com/developers/lesson ... nferences/


Best

Klaus