How to deal with mouse events enable/disable and cursor

0 favourites
  • 5 posts
From the Asset Store
Mouse cursor is something that the player controls and sees all the time, that's why it is so important to make it cool!
  • I suppose this is a strange question but this happens to me all the time. I make education games for charter schools online programs.

    All my games are set up the same basic way:

    1- intro screen with a button to go to an help screen/layout

    2- a helpscreen before game that goes to the game screen/layout

    3- the game screen that contains 3 buttons - help, reset, and music. as well as other navigation buttons depending on the game.

    All buttons are made in a family for which I set the mouse cursor to hand on mouse over.

    Now when the user clicks on the help button, the help screen copy now on the HUD layer slides in.

    My problem is that even if I disable the buttons by disabling groups, there is still the problem of having the button cursors showing through which is a no-no. I have tried to move out buttons off the screen but sometimes it is very difficult when there are lots of elements with hand cursor.

    Is there another way I should approach this which is always happening in all the games?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Set some kind of toggle variable condition so that when the help is open, the mouseover event doesnt work. So wherever the mouseover change event is, add if helpOpen=0 or something. When you open the help, set helpOpen to 1. This will mean the mouseover change to a hand won't work when the help is open.

  • resdesign

    there are a couple ways you could do it.

    If the help screen doesn't have a button that needs the pointer to change to the hand, then put the event that changes the cursor to the hand inside the group that you disable - so you effectively disable the buttons and disable changing the cursor at the same time. When you re-enable the group, you will enable the cursor to change again too.

    If you want to disable some buttons, but still have others work (and have the cursor change), then you could add a boolean instance variable to the family called "ButtonEnabled". Set the variable to False for all the buttons you want to disable, and leave it True for the rest.

    On the event that changes the cursor (when the mouse is over a member of the button family) add another condition that says "ButtonFamily is ButtonEnabled"

    If you have lots of buttons in different groups, you could add another family instance variable called ButtonGroup. Then you could have a "Navigation" group, "Help" group, "Settings" group, "controls" group, etc... Then it would be easy to select and disable/enable an entire group as needed.

  • Thank you guys for your answers and yes the solution is to use families and instance variables. Diego, a friend gave me the idea of using instance variables. Below is the description of the example. Not sure what this forum system is to post examples. Let me know and I can post it.

    Example:

    Set up:

    The stage has the following elements:

      musicBtn - code toggles music and changed the frame image of the button resetBtn - code resets the layout helpBtn - code sets the Y of the help screen to 0

    family is called pointables - the instance variable is cursorStyle = 1

    Above the stage and therefore hidden are:

    help screen

    closeBtn - the button is pinned to the help screen - the instance variable is cursorStyle = 1

    Code:

    1- if mouse is over over pointables and pointables instance variable is 1 then set cursor to hand

    2- if mouse is NOT over pointables then set cursor to normal - set closeBtn instance variable cursorType = 1

    3- helpBtn click event - set pointabled instance variable cursorType = 0 - set help screen Y = 0 set MUSIC BUTTON group Deactivated set RESET BUTTON group Deactivated

    4- closeBtn - set help screen Y = -500 - set pointables cursorType = 1 set MUSIC BUTTON group Activated - set RESET BUTTON group Activated

    So with lots of buttons it is more complicated but you get the idea. There is also the idea to add global variables to set and reset the instance variables.

  • AllanR

    Your response is great too. I will try to implement your answer sometime soon and see how it works. But just reading it seems very promising.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)