Hi,
I'm developing a first person adventure game and I want change the graphic mouse cursor on an hotspot hover event.
How can I do it?
I tried with this code but nothing happens:
// room script file
function hDoorBedroomHall_MouseMove()
{
Mouse.ChangeModeGraphic(eModeLeft, 12); //12 is the ID cursor
}
function hDoorBedroomHall_AnyClick()
{
cChecco.ChangeRoom(3);
}
Many thanks.
Ciao millennium,
I think it won't work that way.
You should do something like that:
Suppose you have some mouse cursors called: eModeLeft, eModeRight, eModeForw, eModeLook, eModeInteract, eModeDefault
(it's only an example)
And suppose you have in your room 3 hotspot (hHOT1, hHOT2, hHOT3), 1 object (oOBJ1), 1 character (cGIOVANNI)
(it's only an example)
create a REPEAT EXECUTE in your room :
function room_RepExec()
{
if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hotspot[0] && Object.GetAtScreenXY(mouse.x, mouse.y) == null && Character.GetAtScreenXY(mouse.x, mouse.y) == null)
{
mouse.UseModeGraphic(eModeDefault);
mouse.Mode = eModeDefault;
}
else
{
if (Character.GetAtScreenXY(mouse.x, mouse.y) == cGIOVANNI) {mouse.UseModeGraphic(eModeLook); mouse.Mode = eModeLook;}
if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hHOT1) {mouse.UseModeGraphic(eModeLeft); mouse.Mode = eModeLeft;}
if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hHOT2) {mouse.UseModeGraphic(eModeRight); mouse.Mode = eModeRight;}
if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hHOT3) {mouse.UseModeGraphic(eModeForw); mouse.Mode = eModeForw;}
if (Object.GetAtScreenXY(mouse.x, mouse.y) == oOBJ1) {mouse.UseModeGraphic(eModeInteract); mouse.Mode = eModeInteract;}
// add other if ... here
}
}
REPEAT THAT THING in EACH ROOM (with its ojects hotspots, etc.)
then... to make something appening on mouse click just create the function ANYCLICK
for example:
function hHOT1_AnyClick()
{
cChecco.ChangeRoom(3);
}
Doing this on a per room and per hotspot basis is the absolute last resort.
What you probably need is GetLocationType:
// in GlobalScript.asc
int old_lt;
function repeatedly_execute() // this function is already there
{
int lt = GetLocationType(mouse.x, mouse.y);
if (lt != old_lt) {
if (lt == eLocationHotspot) {
// mouse just moved over a hotspot
Hotspot *h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
...
}
}
old_lt = lt;
... // other content
}
You can now change the mouse cursor graphic/mode to a generic one, but you can also use for instance a custom property to use an arrow pointing in a certain direction, or other stuff.
To do this, you have to add a suitable custom property to hotspots (look it up in the manual), then use something like:
int property = h.GetProperty("cursor");
if (property == 1) mouse.ChangeModeGraphic(eModeInteract, NORTH_ARROW); // actual slot # here
Hello guys, thanks for the answers but both solutions does not work.
@Khris, this code is not clear:
Hotspot *h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
...
Thanks.
Solved. It's really easy.
function hDoorBedroomHall_MouseMove()
{
mouse.SaveCursorUntilItLeaves();
mouse.Mode = eModeLeft;
}
function hDoorBedroomHall_AnyClick()
{
cChecco.ChangeRoom(3);
}