Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: mistermor on Fri 07/08/2009 14:41:46

Title: the sound playing repeadely when crossing room's edge
Post by: mistermor on Fri 07/08/2009 14:41:46
hi... i am having a problam-
i want my character to go to the toilet whenever he is crossing the left room edge.
so- my plan was to make my character go outside the left border of the room, to play a "flush" sound, and then to go back to the room from the left border of the room.

the problam is that the FLUSH sound plays over and over again (doubled sound) until my computer crash. i am pretty sure it is due to the fact that it plays (over and over again) as long as i am outside the left edge. i want it to play only ONCE!


function room_LeaveLeft()
{
 cEgo.Walk(-30,  cEgo.y, eBlock, eAnywhere);
 PlaySound(3);
 
 
 cEgo.Walk(60 , cEgo.y);

}


Title: Re: the sound playing repeadely when crossing room's edge
Post by: Matti on Fri 07/08/2009 14:54:47
When you make the 2nd walk command blocking, then the sound shouldn't be played..
Title: Re: the sound playing repeadely when crossing room's edge
Post by: Khris on Fri 07/08/2009 19:07:40
You also might want to add a Wait(40); after the PlaySound command.
Title: Re: the sound playing repeadely when crossing room's edge
Post by: mistermor on Fri 07/08/2009 20:56:59
Quote
When you make the 2nd walk command blocking, then the sound shouldn't be played.

well- thats never happend, because my character never able to astablish this walk command- my AGS get stuck much before.

Quote
You also might want to add a Wait(40); after the PlaySound command.
that did not help too. why? because after the wait(40) command, my character is steel behind the edge line, so the playsound command still repeatedly executed.

my solution was to use Hotspot instead of room's edges.
i wasnt able to make it with edges though.
this is my final, working code:

function hHotspot1_WalkOn()
{
 cEgo.Walk(-40, cEgo.y, eBlock, eAnywhere);
 Display("after 10 minutes");
 PlaySound(2);
 Wait(100);
 cEgo.Walk(40, cEgo.y, eBlock, eAnywhere);

}


if someone has a better solution, with edges, please notify me...

Title: Re: the sound playing repeadely when crossing room's edge
Post by: tzachs on Sat 08/08/2009 12:21:06
Maybe something like this will do the trick (I'm assuming the 60 is to the right of the left edge):


bool crossedLeftEdge;

function room_LeaveLeft()
{
  if (!crossedLeftEdge)
  {
      crossedLeftEdge = true;
      cEgo.Walk(-30,  cEgo.y, eBlock, eAnywhere);
      PlaySound(3);
   
      cEgo.Walk(60 , cEgo.y);
      crossedLeftEdge = false;
  }

}