Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gabarts on Sat 21/06/2014 12:17:56

Title: Scenery with hotspots {Solved}
Post by: Gabarts on Sat 21/06/2014 12:17:56
I'm creating a scenery. It's not like this but similar.

(http://i62.tinypic.com/2yugigo.jpg)

Basically I have 3-4 doors and I want that white text "door" or "entrance" appear when mouse is over. No GUI, no inventory, no interface, just the player moving in the scenery and cursor. Then I want a ChangeRoom when clicking in the hotspots.

Any idea on how to create this? I'm using the 9-Verb, you know the game I'm doing... Thanks
Title: Re: Scenery with hotspots (without GUI)
Post by: Khris on Sat 21/06/2014 13:44:17
You need a GUI with a label on it that says @OVERHOTSPOT@
This will insert the location name when the mouse is on top of any active location.
To have it move with the mouse, set the GUI's position to the mouse's in room_RepExec.

(also, asked and answered many times, please use the search first in case you didn't)
Title: Re: Scenery with hotspots (without GUI)
Post by: Gabarts on Sat 21/06/2014 14:40:12
I was searching something but didn't know the function @OverHotspot@. Something like this?

Example (http://www.adventuregamestudio.co.uk/forums/index.php?topic=36068.msg472855#msg472855)

Or I was thinking about also to normal hotspots, placing a ChangeRoom when player move x, y to the hotspot...
Title: Re: Scenery with hotspots (without GUI)
Post by: Cassiebsg on Sat 21/06/2014 15:04:21
I've also been thinking about something like this, and I also did not know about @OverHotspot@.
They way I was going to try and do it was using GetatScreen (mouse.x, mouse.y) == (x, y) and then either do a display or create a new character, call it "cCursor" and get it to be at mouse.x & mouse.y, then just use CCursor.Say...

Would it work? Would it be more complicated than creating a GUI? (I have yet to test it, just thought of this 2 days ago, and I hadn't yet time to test it).
Title: Re: Scenery with hotspots (without GUI)
Post by: Khris on Sat 21/06/2014 15:04:57
If you want the hotspots to react to clicks, just use this in the room script:

Code (ags) Select
void on_mouse_click(MouseButton button) {
  if (button != eMouseLeft) return;
  Hotspot *h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  if (h == hotspot[0]) return false;
  ClaimEvent();
  int id = h.ID;

  if (id == 1) ChangeRoom(...);
  if (id == 2) ChangeRoom(...);
  // etc
}
Title: Re: Scenery with hotspots (without GUI)
Post by: Gabarts on Sat 21/06/2014 15:54:40
This is really good for my need. As soon as I edit the scenery I will give it a try. In this code is included the condition for the player?
I mean only ChangeRoom if the player move x,y when clicking on the hotspot.

Like the usual:

Code (ags) Select
function hHOTSPOT_AnyClick() {
if (MovePlayer(103, 105)) {
      player.FaceDirection(eDir_Left);
   
    if(UsedAction(eGA_LookAt)) {
      player.Say("Now I can enter.");
Title: Re: Scenery with hotspots (without GUI)
Post by: Gabarts on Sun 22/06/2014 16:15:02
Quote from: Khris on Sat 21/06/2014 15:04:57
If you want the hotspots to react to clicks, just use this in the room script:

Code (ags) Select
void on_mouse_click(MouseButton button) {
  if (button != eMouseLeft) return;
  Hotspot *h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  if (h == hotspot[0]) return false;
  ClaimEvent();
  int id = h.ID;

  if (id == 1) ChangeRoom(...);
  if (id == 2) ChangeRoom(...);
  // etc
}


Khris, this gives me error: Cannot return value from void function

I think is better to use the GUI label with OVERHOTSPOT but at the moment I cannot make it...
Title: Re: Scenery with hotspots (without GUI)
Post by: Joe on Sun 22/06/2014 16:54:23
Just replace "void" keyword with "function" or "bool".

EDIT: well actually that might break AGS. Just remove the "false" keyword.
Title: Re: Scenery with hotspots (without GUI)
Post by: Gabarts on Sun 22/06/2014 17:13:07
Thanks anyway. It was easier then I tought. I've made a GUI label only visible for the scenery with OVERHOTSPOT and changing room with the normal hHotspot_AnyClick(). It's fine now ;-D