Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Vault15 on Sun 14/10/2012 22:40:13

Title: (SOLVED) Mouse Cursor Changing from Active Screen to Gui?
Post by: Vault15 on Sun 14/10/2012 22:40:13
Hey, I just had another quick question. Now that I have my Gui setup nicely, I just want the mouse cursor to change automatically when moving to it at the bottom.

Would I need to add something in the "#sectionstart repeatedly_execute" part of the globalscript or is there a better way? I am able to solve many of my problems with the included manual (incase anyone thinks to mention it). I just haven't quite got the gist of scripting.


Thanks again!
Title: Re: Mouse Cursor Changing from Active Screen to Gui?
Post by: geork on Sun 14/10/2012 23:10:15
If you want the mouse cursor to change when it moves over the GUI, use GUI.GetAtScreenXY(x,y). This approach will mean it's in repeatedly_execute(), but I can't really think of another function to put it in, since AGS has to constantly check whether the mouse is in a certain area... 
something like:
Code (AGS) Select

function repeatedly_execute(){
  if(GUI.GetAtScreenXY(mouse.x, mouse.y) == gGUI && Mouse.Mode != eModePointer) { //you'll want to check whether the mouse mode has already been changed...no point doing it twice!
    Mouse.Mode = eModePointer;
  }
  //probably other code
}

Where "gGUI" is the name of your GUI

Hope this solves it :)
Title: Re: Mouse Cursor Changing from Active Screen to Gui?
Post by: Khris on Sun 14/10/2012 23:13:06
Quote from: Vault15 on Sun 14/10/2012 22:40:13"#sectionstart repeatedly_execute"

Wait a second, "#sectionstart"...?
Are you using some old game template? Or tutorial?

The "#sectionstart" stuff was discontinued as of AGS 3.0.
Title: Re: Mouse Cursor Changing from Active Screen to Gui?
Post by: Vault15 on Sun 14/10/2012 23:23:00
Quote from: geork on Sun 14/10/2012 23:10:15
If you want the mouse cursor to change when it moves over the GUI, use GUI.GetAtScreenXY(x,y). This approach will mean it's in repeatedly_execute(), but I can't really think of another function to put it in, since AGS has to constantly check whether the mouse is in a certain area... 
something like:
Code (AGS) Select

function repeatedly_execute(){
  if(GUI.GetAtScreenXY(mouse.x, mouse.y) == gGUI && Mouse.Mode != eModePointer) { //you'll want to check whether the mouse mode has already been changed...no point doing it twice!
    Mouse.Mode = eModePointer;
  }
  //probably other code
}

Where "gGUI" is the name of your GUI

Hope this solves it :)


Fantastic, thanks for the quick response! All I did was substitute my Gui in the code and it changed as I wanted. By the way, when I move the cursor back to the main area, what's the script to set it back to my mouse cursor 0 (first one)? I feel like if I force it back it will interfere with how it's currently set up. I have it where I right click in the main screen and it changes from look, use, talk, walk. I almost want to leave it as is, but if there's some simple code I can add then I'm all for it =P
Title: Re: Mouse Cursor Changing from Active Screen to Gui?
Post by: Vault15 on Sun 14/10/2012 23:28:06
Quote from: Khris on Sun 14/10/2012 23:13:06
Quote from: Vault15 on Sun 14/10/2012 22:40:13"#sectionstart repeatedly_execute"

Wait a second, "#sectionstart"...?
Are you using some old game template? Or tutorial?

The "#sectionstart" stuff was discontinued as of AGS 3.0.

Well, you got me there. I noticed this template had a different method of doing that vs my other game using newer code. I guess I figured there's no point changing it. My game has nothing to do with this so I deleted almost everything but the shell and Smooth Scrolling/Parallax scripts. The reason being that I couldn't seem to get the smooth scroll to work starting from scratch. The guy who came up with that is brilliant and it is a huge building block to my project.

Edit: The 1 screen game came with the script to demonstrate what it can do. It's a very helpful tutorial sortof thing.
Title: Re: Mouse Cursor Changing from Active Screen to Gui?
Post by: Vault15 on Sun 14/10/2012 23:45:02
Quote from: geork on Sun 14/10/2012 23:10:15
Hope this solves it :)

I added to your code once I figured out what was going on. Here's what I ended up with to make it 100% what I wanted =]

Thanks again.

Code (AGS) Select
function repeatedly_execute()
{
  // put anything you want to happen every game cycle here

  if(gIconbar.GetAtScreenXY(mouse.x, mouse.y) == gIconbar && Mouse.Mode != eModeUsermode3)
  {
    Mouse.Mode = eModeUsermode3;
  }
  else if(gIconbar.GetAtScreenXY(mouse.x, mouse.y) != gIconbar && Mouse.Mode == eModeUsermode3)
  {
    Mouse.Mode = eModeWalkto;
  }
  //probably other code

}