Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: subspark on Sat 29/08/2009 22:20:45

Title: [SOLVED] HELP with ViewFrame.LinkedAudio
Post by: subspark on Sat 29/08/2009 22:20:45
For some reason, when my character is already walking, the footstep sounds play, but when the view is changed i get the following error:
GetGameParameter: invalid frame specified

That being said, my frames and linked sound files are right on the money. I don't understand how a valid frame can be inconsistently invalid.
Also there isn't any real example of how to set the ViewFrame sound in the manual.

Heres my hideous code:
function room_RepExec()
{
 //===== FOOTSTEP SOUNDS - ANTE CHAMBER =====//
 
 ViewFrame *vf;
 int Down, Left, Right, Up, DownRight, UpRight, DownLeft, UpLeft;
   
   // Down
   vf = Game.GetViewFrame(WALK, Down, 0);
   vf.LinkedAudio = aFootstep_solid_2_fx; // idle footstep
   vf = Game.GetViewFrame(WALK, Down, 4);
   vf.LinkedAudio = aFootstep_solid_1_fx; // regular footstep A
   vf = Game.GetViewFrame(WALK, Down, 8);
   vf.LinkedAudio = aFootstep_solid_1_fx; // regular footstep B
   
   // Left
   vf = Game.GetViewFrame(WALK, Left, 0);
   vf.LinkedAudio = aFootstep_solid_2_fx; // idle footstep
   vf = Game.GetViewFrame(WALK, Left, 5);
   vf.LinkedAudio = aFootstep_solid_1_fx; // regular footstep A
   vf = Game.GetViewFrame(WALK, Left, 9);
   vf.LinkedAudio = aFootstep_solid_1_fx; // regular footstep B
   
   // Right Etc.


Any ideas?

Cheers,
Sparky.
Title: Re: HELP with ViewFrame.LinkedAudio
Post by: Gilbert on Sat 29/08/2009 22:47:11
I don't understand. This line:

int Down, Left, Right, Up, DownRight, UpRight, DownLeft, UpLeft;

just declares a brunch of variables named as directions, which probably initialised to 0 or just holding unknown values (as far as I remember, variables declared out of functions are initialised as 0, but those within functions may be set to unknown values; don't know whether this has changed).

Then, you just use them immediately?
Title: Re: HELP with ViewFrame.LinkedAudio
Post by: subspark on Sat 29/08/2009 23:58:42
Genius Gilbet! Your a godsend, mate. 8)

The solution:
int Down = 0, Left = 1, Right = 2, Up = 3, DownRight = 4, UpRight = 5, DownLeft = 6, UpLeft = 7;

Cheers,
Sparky.
Title: Re: [SOLVED] HELP with ViewFrame.LinkedAudio
Post by: Shane 'ProgZmax' Stevens on Sun 30/08/2009 21:23:36
Also, you are aware that the loop editor allows you to specify a sound for each frame from the UI?

(http://i485.photobucket.com/albums/rr218/ProgZmax/soundsetting.gif)