problems with the "PlayMusic();" Command

Started by Fuchs, Tue 14/02/2012 16:34:10

Previous topic - Next topic

Fuchs

Hello everyone!
I am rather new to AGS but I went through all of the existing Tutorials on Youtube and also I red the whole AGS-Tutorial/ book. So I feel kind of familiar with the overall idea.
But one thing is really striking my mood down right at the beginning of my project.
When I want to play a sound, any sound, (especially music) AGS just wont let me do this. It appears that in the Script Editor, I am not given the "PlayMusic" or "PlaySound" Command option.
Every time I type it in the error "room1.asc(5): Error (line 5): Undefined token 'PlayMusic'" occurs.
This is strange because I proceed exactly as in the tutorials. My AGS just acts as if there was no such command.
Further than that there is no problem with the files or sound adjustments. As I added the walkingsound in the character View, everything was just fine and the game would play the sound. But I need background music and other sounds and somehow it wont work.
So I hope that some of you might have an idea?! It would be really nice. I am kind of thrown back now that one of the most easiest and important functions seem not to work on my game.:-(
Thank you guys in advance!

Atelier

Hi Fuchs, you must be using the newest version of AGS, and watching outdated tutorials. The command PlayMusic is now obsolete, it got replaced with aMusic.Play, where aMusic is the name of the track you want. Press F1 while in the editor and you'll get a list of commands.

Ryan Timothy B

Because PlayMusic is now obsolete. Look in the manual for Play.

You add the music file into the audio branch of the project tree. Then simply call it by name like so:

aExplosion.Play();

Fuchs

Quote from: Ryan Timothy on Tue 14/02/2012 16:43:46
Because PlayMusic is now obsolete. Look in the manual for Play.

You add the music file into the audio branch of the project tree. Then simply call it by name like so:

aExplosion.Play();

Ah i see, now the Errormessage is no longer occuring. Thank you very much Ryan and Atelier!
Only i cant hear the sound somehow. (usually the sounds i import are really loud and i have to turn them down in volume)
Is the AmbienteSound having the same command? And can i still define its source through the x and y coordinates like it was possible in the old versions?

Fuchs

Quote from: Atelier on Tue 14/02/2012 16:41:34
Hi Fuchs, you must be using the newest version of AGS, and watching outdated tutorials. The command PlayMusic is now obsolete, it got replaced with aMusic.Play, where aMusic is the name of the track you want. Press F1 while in the editor and you'll get a list of commands.
Thank you very much for your quick reply. But there is still a problem: due to the changes of this command, i dont quite know how to set the sound-source.
Lets say i have a machine humming or whatever emmitting from a certain point in the room, how can i tell AGS where this is? (in the old Play.AmbientSound i had the optional x,y coordinates in the () ,where are they now???)

Khris

You have to store the AudioChannel returned by the .Play command, then change its .Panning:

Code: ags
  AudioChannel*ac = aHumming.Play();
  ac.Panning = -80;  // mostly left speaker

SMF spam blocked by CleanTalk