Enter from an edge

Started by DrakeStoel, Thu 08/12/2011 05:56:45

Previous topic - Next topic

DrakeStoel

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   :=

Khris

Just check player.PreviousRoom.

Code: ags
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:
Code: ags
  // entered from top edge
  if (player.y < 20) ...

monkey0506

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):

Code: ags
player.Walk(x, y, eBlock, eAnywhere);


By default the parameter is set to use eWalkableAreas.

DrakeStoel

Yup. That works. Thanks guys  :=

SMF spam blocked by CleanTalk