Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: stepsoversnails on Fri 25/03/2011 18:34:02

Title: SetFrameSound not working
Post by: stepsoversnails on Fri 25/03/2011 18:34:02
I'm trying to set up regions with different walking sounds.
so naturally i'm using the SetFrameSound function.
but, after entering the code into the regions walks onto event and trying to run the game it comes up with the error: room1.asc(9): Error (line 9): Undefined token 'SetFrameSound'

I thought this function was built into the editor. Why would it come up as an undefined token? Or is there something i'm missing here?
Title: Re: SetFrameSound not working
Post by: monkey0506 on Fri 25/03/2011 19:05:09
Which version of AGS are you using?

Neither 3.2 nor 3.2.1 have been "officially" released, but they are the only versions using the new-style audio system, which appears to be your problem.

The newest, but as-yet unofficial versions use the ViewFrame.LinkedAudio property instead of SetFrameSound. Try that.
Title: Re: SetFrameSound not working
Post by: proximity on Tue 26/04/2011 21:57:53
So, how exactly can we change current frame sound with using LinkedAudio property ?
Title: Re: SetFrameSound not working
Post by: monkey0506 on Tue 26/04/2011 22:22:08
Just set the LinkedAudio property directly:

ViewFrame *frame = Game.GetViewFrame(player.View, player.Loop, player.Frame);
frame.LinkedAudio = aFootstep;
Title: Re: SetFrameSound not working
Post by: proximity on Tue 26/04/2011 22:39:48
Quote from: monkey_05_06 on Tue 26/04/2011 22:22:08
Just set the LinkedAudio property directly:

ViewFrame *frame = Game.GetViewFrame(player.View, player.Loop, player.Frame);
frame.LinkedAudio = aFootstep;


I tried that but it says "cannot convert audio channel to audio clip.
Title: Re: SetFrameSound not working
Post by: monkey0506 on Wed 27/04/2011 04:26:44
LinkedAudio is an AudioClip. You assign it the value of an audio clip as set in the editor, not the AudioChannel the clip is playing on.
Title: Re: SetFrameSound not working
Post by: proximity on Wed 27/04/2011 13:08:01
Hmmm you're right. I may have use it like LinkedAudio.Play. It worked with your code, thanks monkey.
Title: Re: SetFrameSound not working
Post by: monkey0506 on Thu 28/04/2011 00:34:45
You're welcome. And just to be clear:

// works!!
if (frame.LinkedAudio != null) frame.LinkedAudio.Play();


// works!!
frame.LinkedAudio = aFootstep;


// doesn't work! D:
frame.LinkedAudio = aFootstep.Play();


That last one is probably what you mistakenly did. Glad you got it working though. :)