It's me, again, bothering you with a silly question.
I'm making a first person game, and took the advice(which is actually very useful) from another post that one should use only 1 type of cursor.
I have the following code :
function room_AfterFadeIn() {
Wait(30);
gBlack1.Visible = false;
Wait(30);
gBlack2.Visible =false;
mouse.UseModeGraphic(eModeInteract);
Mouse.Mode = eModeInteract;
mouse.Visible = true;
}
Because I want the cursor to appear after the fade-in. so far so good !
I added the following code to the hotspot, advice taken from some forum post
function hHotspot1_MouseMove()
{
mouse.SaveCursorUntilItLeaves();
mouse.ChangeModeGraphic(mouse.Mode, 24);
}
The thing is, after moving back the cursor from the hotspot, the same 'changed' graphic persists, not reverting back to its original graphic that I selected(and that it was present before hovering to the hotspot). In the documentation it is written to put the 'savecursoruntillitleaves' think BEFORE the changing - which I did - to actually prevent that from happening. I tried to add the
" Mouse.Mode = eModeInteract;
mouse.UseModeGraphic(eModeInteract);
"
into the global script, but that does not seem to work. also, others 'update' functions relating to the mouse when put into the "global script" again do not work =(.
Can you please provide a more correct code or point me out in the direction of what I'm doing wrong, please ?
You have changed the graphic, not the mode. For that reason mouse.SaveCursorUntilItLeaves(); has no effect.
To be fair, the function should probably be named mouse.SaveModeUntilItLeaves(); :P
Anyway, to change the cursor over a hotspot, you should implement this behavior globally. Here's one way:
// above repeatedly_execute
LocationType plt;
// inside repeatedly_execute
LocationType lt = GetLocationType(mouse.x, mouse.y);
if (lt != eLocationNothing && plt == eLocationNothing) {
// mouse moved over active area
mouse.ChangeModeGraphic(eModeInteract, 24);
}
else if (lt == eLocationNothing && plt != eLocationNothing) {
// mouse left active area
mouse.ChangeModeGraphic(eModeInteract, 23); // correct sprite slot goes here
}
plt = lt;