Sound Trouble (SOLVED)

Started by R4L, Thu 21/09/2006 02:36:00

Previous topic - Next topic

R4L

Ok, I went on FindSounds.com and got a sound for a metal wheel turning, and it came in AIFF format. I opened up Cool Edit Pro and did some changes to make it shorter, faster, and louder, and then I saved it as a wav file. Then, when the player interacts with a valve, this code is run:

Code: ags

Ã,  // script for Object 0 (Valve): Interact object
cEgo.Walk(212, 143,eBlock,eWalkableAreas);
cEgo.FaceLocation(212, 140,eBlock);
if (GetGlobalInt(412) == 2){
Ã,  cEgo.Say("I already did that.");
Ã,  return;
}
cEgo.LockView(9);
cEgo.Animate(1, 5, eOnce, eBlock, eForwards);
while (cEgo.Animating){
Ã,  PlaySound(105);
Ã,  Wait(1);
}
cEgo.UnlockView();
cEgo.Say("I turned the valve.");Ã,  
cEgo.FaceLocation(206, 143,eBlock);
oErmky.Visible = true;
oErmky.Move(141, 141, 10, eBlock,eAnywhere);
Wait(40);
cEgo.Say("Aha, slowly unveiling this mystery, one puzzle at a time.");
SetGlobalInt(412, 2);


For some reason, the sound does not play. Is it because the sound is short? The sound itself only goes for about 0.493 seconds, but I don't think this is the problem. What am I doing wrong?

Gilbert

I'm not sure, but if the sample is about 0.5 s long, shouldn't it be simething like:

Code: ags

while (cEgo.Animating){
Ã,  PlaySound(105);
Ã,  Wait(20);
}


Since at default setting there're 40 loops in 1 second.
(Or experiment with other numbers until it's optimal.)

Or more "accurately" you may do (especially in a game that the game speed can vary):

Code: ags

while (cEgo.Animating){
Ã,  PlaySound(105);
Ã,  Wait(FloatToInt(0.493 * IntToFloat(GetGameSpeed()), eRoundNearest));
}



R4L

#2
Ok, I tried both, but still nothing. I appreciate your help so far.

EDIT: I figured it out! I had to change the eBlock in cEgo.Animate to eNoBlock, it was blocking my while statement I think. Thanks for helping me though!   :)

SMF spam blocked by CleanTalk