Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: danbuddle on Sun 23/02/2014 21:10:12

Title: Displaying message when player leaves room is causing glitch
Post by: danbuddle on Sun 23/02/2014 21:10:12
I am a little stuck on this and can't find any other info on the forums relating to it. I want to display a message when the player walks off the screen. So under actions in edges I have set room_Leave right and top to display a message using the display code.

Code (adg) Select
function room_LeaveTop()
{
Display("I can't leave now. There's too much to be done.");
}

function room_LeaveRight()
{
Display("I can't leave now. There's too much to be done.");
}

function room_LeaveLeft()
{
Display("I can't leave now. There's too much to be done.");
}


However, the character walks over the edge, triggering the message, but it causes a glitch whereby the walk animation carries on, trying to complete and reach where the player has clicked and re-displaying the message over and over with each tiny movement of the character. I have to keep clicking the message off over and over again to allow the animation to finish if I want to carry on playing.

Any ideas on how to display messages using the leave command without this happening? Many thanks
Dan.
Title: Re: Displaying message when player leaves room is causing glitch
Post by: Khris on Sun 23/02/2014 22:36:46
Looks like the event is triggered by "player is beyond edge", not "player stepped beyond egde", but I've never used this so I didn't know either and also never read this anywhere.
A quick fix is to simply make the player move back blockingly:
Code (ags) Select
function room_LeaveTop()
{
  Display("I can't leave now. There's too much to be done.");
  player.Walk(player.x, 20, eBlock); // walk straight down
}

This should prevent the event from firing again until they reached the new position back inside of the edge.

You could also use a region instead and use its "player walks onto event", which will not fire a second time until they leave and enter the region again.
Title: Re: Displaying message when player leaves room is causing glitch
Post by: danbuddle on Mon 24/02/2014 18:27:15
Perfect.
Regions seem much more appropriate and work.
Thank you kindly.
Dan.