Dear AGS'ers, I'm trying to convert the old style coding for audio to the new format.
I have no clue where to begin. Ags tells me that I can't convert an AudioClip to an int which makes sense but its been so long away from scripting I've lost my touch.
This is my current code (old format):
function room_RepExec()
{
//===== FOOTSTEP SOUNDS =====//
ViewFrame *vf;
int fstep, idle, norm;
if (Region.GetAtRoomXY(player.x, player.y) == region[2]) {
idle = footstep2Bfx; norm = footstep2Afx;
}
else {
idle = footstep1Bfx; norm = footstep1Afx;
}
while (fstep<8) {
vf = Game.GetViewFrame(EGOWALK, fstep, 0);
vf.Sound = idle; // idle footstep
vf = Game.GetViewFrame(EGOWALK, fstep, 4);
vf.Sound = norm; // regular footstep
vf = Game.GetViewFrame(EGOWALK, fstep, 10);
vf.Sound = norm; // regular footstep
fstep++;
}
}
As you might see, its a little dated. Anything I'm missing that I need to add in order for this function to work with the latest incarnation of AGS?
Merry wishes,
Sparky.
You have to use ViewFrame.LinkedAudio, so you would do something like to set the association:
vf = Game.GetViewFrame(EGOWALK, fstep, 0);
vf.LinkedAudio = aNorm; // idle footstep
So to use a variable AudioClip for region sounds, you will need to declare the AudioClip instead of an int:
function room_RepExec()
{
//===== FOOTSTEP SOUNDS =====//
ViewFrame *vf;
int fstep;
AudioClip *idle;
AudioClip *norm;
if (Region.GetAtRoomXY(player.x, player.y) == region[2]) {
idle = aFootstep2Bfx; norm = aFootstep2Afx;
}
else {
idle = aFootstep1Bfx; norm = aFootstep1Afx;
}
while (fstep<8) {
vf = Game.GetViewFrame(EGOWALK, fstep, 0);
vf.LinkedAudio = idle; // idle footstep
vf = Game.GetViewFrame(EGOWALK, fstep, 4);
vf.LinkedAudio = norm; // regular footstep
vf = Game.GetViewFrame(EGOWALK, fstep, 10);
vf.LinkedAudio = norm; // regular footstep
fstep++;
}
}
Note that I here assumed that the sounds have been renamed adding an 'a' to the beginning - not sure if AGS actually does this when updating the game to 3.2.
Edit: Fixed the code in case someone else wants to use it, of course the variable fstep should still be an int, not an AudioClip.
Most appreciated, gg. Hope everyone has a funtastic new years eve and a great start to 2010.
Cheers,
Sparky