Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: DrakeStoel on Thu 08/12/2011 05:56:45

Title: Enter from an edge
Post by: DrakeStoel on Thu 08/12/2011 05:56:45
I'm trying to figure out how to make my character walk to a different points after entering from different edge. So if he enters from the left edge, he goes somewhere, the right edge, somewhere else. That sort of thing. Any help would be appreciated   :=
Title: Re: Enter from an edge
Post by: Khris on Thu 08/12/2011 10:39:24
Just check player.PreviousRoom.

function room_AfterFadein() {

  // entered from left edge
  if (player.PreviousRoom == 2) player.Walk(30, 120);

  ...
}


If you don't want to use the room numbers all the time, you could also check the player's coordinates:
  // entered from top edge
  if (player.y < 20) ...
Title: Re: Enter from an edge
Post by: monkey0506 on Thu 08/12/2011 12:51:23
Also, if you want to make them walk into the room from off-screen, then you'll need to pass the BlockingStyle and WalkWhere parameters (you have to pass BlockingStyle because it comes before WalkWhere):

player.Walk(x, y, eBlock, eAnywhere);

By default the parameter is set to use eWalkableAreas.
Title: Re: Enter from an edge
Post by: DrakeStoel on Thu 08/12/2011 21:40:09
Yup. That works. Thanks guys  :=