[SOLVED] HELP with ViewFrame.LinkedAudio

Started by subspark, Sat 29/08/2009 22:20:45

Previous topic - Next topic

subspark

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:
Code: ags
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.

Gilbert

I don't understand. This line:
Code: ags

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?

subspark

Genius Gilbet! Your a godsend, mate. 8)

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


Cheers,
Sparky.

Shane 'ProgZmax' Stevens

Also, you are aware that the loop editor allows you to specify a sound for each frame from the UI?


SMF spam blocked by CleanTalk