Newbie ChangeModeGraphic/SaveCursorUntilItLeaves question

Started by mr52pickup, Thu 26/03/2009 23:23:44

Previous topic - Next topic

mr52pickup

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.

Khris

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:

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


There's another way though: add a Custom property 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:

Code: ags
  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.

mr52pickup

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.


SMF spam blocked by CleanTalk