Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: mr52pickup on Thu 26/03/2009 23:23:44

Title: Newbie ChangeModeGraphic/SaveCursorUntilItLeaves question
Post by: mr52pickup on Thu 26/03/2009 23:23:44
I've tried my best to research this first, but....
I'm having a problem with changing the cursor while it is over a hotspot using SaveCursorUntilItLeaves followed by ChangeModeGraphic. The cursor fails to return to the default after moving off the hotspot. I've seen several posts for this problem, but every answer I see involves using edges or x,y co-ordinates. I want to have a hotspot that takes the player to another room. Here is my script:

function hHotspot1_MouseMove()
{
mouse.SaveCursorUntilItLeaves();
mouse.ChangeModeGraphic(eModeLookat, 6);
mouse.UseDefaultGraphic();

}

I've tried it with and without the UseDefaultGraphic line.
Title: Re: Newbie ChangeModeGraphic/SaveCursorUntilItLeaves question
Post by: Khris on Fri 27/03/2009 00:08:30
Just like is explained in the manual and shown in the example, mouse.SaveCursorUntilItLeaves(); is used to store the cursor mode, not the cursor mode's graphic.
And since you don't change the mode but (permanently) change the mode's graphic, this isn't reverted upon leaving the hotspot.

I assume you want to display an exit arrow?
Add a cursor mode (eModeExit), then do:

function hHotspot1_MouseMove() {
  mouse.SaveCursorUntilItLeaves();
  mouse.ChangeModeGraphic(eModeExit, 6);
  mouse.Mode = eModeExit;
}


There's another way though: add a Custom property (http://www.adventuregamestudio.co.uk/manual/Custom%20Properties.htm) called "exit" of type int, default value 0.
For every exit hotspot, set it to a value (other than 0) representing the direction.

In the global repeatedly_execute(), add:

  Hotspot*h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  int ex = h.GetProperty("exit");
  if (ex > 0 && mouse.Mode != eModeExit) {  // mouse just moved over an exit hotspot
    mouse.SaveCursorUntilItLeaves();
    mouse.ChangeModeGraphic(eModeExit, ex);
    mouse.Mode = eModeExit;
  }


This'll probably save you a load of tying/repetitive code.
Title: Re: Newbie ChangeModeGraphic/SaveCursorUntilItLeaves question
Post by: mr52pickup on Fri 27/03/2009 02:53:20
Thank you, KhrisMUC. That worked. I actually DID try to find this in the manual; but what I found was obviously not the same part you are refering to. There was very little detail. Anyway, thanks again.
Title: Re: Newbie ChangeModeGraphic/SaveCursorUntilItLeaves question
Post by: Khris on Fri 27/03/2009 16:06:44
I was referring to this part:
http://www.adventuregamestudio.co.uk/manual/Mouse.SaveCursorUntilItLeaves.htm