Scenery with hotspots {Solved}

Started by Gabarts, Sat 21/06/2014 12:17:56

Previous topic - Next topic

Gabarts

I'm creating a scenery. It's not like this but similar.


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

Khris

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)

Gabarts

#2
I was searching something but didn't know the function @OverHotspot@. Something like this?

Example

Or I was thinking about also to normal hotspots, placing a ChangeRoom when player move x, y to the hotspot...

Cassiebsg

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).
There are those who believe that life here began out there...

Khris

If you want the hotspots to react to clicks, just use this in the room script:

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

Gabarts

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
function hHOTSPOT_AnyClick() {
if (MovePlayer(103, 105)) {
      player.FaceDirection(eDir_Left);
   
    if(UsedAction(eGA_LookAt)) {
      player.Say("Now I can enter.");

Gabarts

#6
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
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...

Joe

#7
Just replace "void" keyword with "function" or "bool".

EDIT: well actually that might break AGS. Just remove the "false" keyword.
Copinstar © Oficial Site

Gabarts

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

SMF spam blocked by CleanTalk