Displaying message when player leaves room is causing glitch

Started by danbuddle, Sun 23/02/2014 21:10:12

Previous topic - Next topic

danbuddle

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
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.
I really have nothing to say...

Khris

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
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.

danbuddle

Perfect.
Regions seem much more appropriate and work.
Thank you kindly.
Dan.
I really have nothing to say...

SMF spam blocked by CleanTalk