assign different curser views to different objects when moving curser oover them

Started by onizuka666, Mon 10/02/2014 16:50:25

Previous topic - Next topic

onizuka666

Hey guys,

I know now how to make the curser-view change when moving it over objects using the following script:

int previousLocationType;
void UpdateMouseCursor()
{
  int lt = GetLocationType(mouse.x, mouse.y);
  if (lt != previousLocationType)
  {  // location type has changed as of this game loop
  if (lt == eLocationObject) mouse.Mode = eModePickup;
  else if (lt == eLocationHotspot) mouse.Mode = eModeLookat;
  else if (lt == eLocationCharacter) mouse.Mode = eModeTalkto;
  else mouse.Mode = eModeWalkto;
  }
  previousLocationType = lt;
  }
function room_RepExec()
{
UpdateMouseCursor();
}

Is there also the possibility to make the curser change to different curser-views for different objects when moving the mouse curser over them?

Thanks in advance!

Khris

To store additional info about stuff, you can go two routes, depending on whether this data must be alterable during the game:
either use a custom property, or variables.
Custom properties are built into AGS, and you can create and set them in the properties of an object, or hotspot, etc.
With variables, you can change the values during the game, but it gets a bit more complicated.

In the existing code, instead of say,   if (lt == eLocationObject) mouse.Mode = eModePickup;
you do this:
Code: ags
  if (lt == eLocationObject) {
    Object *o = Object.GetAtScreenXY(mouse.x, mouse.y);
    int value = o.GetProperty("mousemode");  // read object's "mousemode" property
    if (value == 0) mouse.Mode = eModePickup;
    else if (value == 1) mouse.Mode = eModeInteract;
  }

If you set a default value of 0 for the property, just change that to 1 for each Object where you'd rather want to show the interact cursor.

SMF spam blocked by CleanTalk