How do I highlight objects by mouse hover and mouse click

0 favourites
  • 2 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Hi. I have tried to do this myself and found one issue which I cannot solve <img src="{SMILIES_PATH}/icon_neutral.gif" alt=":|" title="Neutral"> . Perhaps it is due to my noobish programming style. I try my best to explain the situation as below:

    LAYOUT

    • There are 5 boxes:
      • Lime
      • Green Forest
      • Black
      • Magenta
      • Purple
    • There are 3 families:
      • GreenBoxes - which contains Lime and Green Forest boxes
      • PurpleBoxes - which contains Magenta and Purple boxes
      • PlayerBox - which contains the Black Box
    • All families have two instance boolean variables:
      • OnHighlight - when mouse is hovered over a box, OnHighlight is set to true for that box. OnHighlight for that box is set to false when mouse is hovered outside that box.
      • OnClicked - when a box is left clicked, OnClicked is set to true for that box. OnClicked for that box is set to false when areas outside that box is left clicked.
    • There are 2 types of highlighter:
      • OnHighlight (OH) highlighter
      • OnClicked (OC) highlighter

    OBJECTIVES MET

    • When mouse is hovered over a box, an OH highlighter appears at the centre of the box. The OH highlighter disappears the moment the mouse is hovered outside the box.
    • When a box is left clicked, an OC highlighter remains even when the mouse is hovered outside the box. The OC highlighter only disappears when areas outside that box is left clicked.
    • For the player box (black box), when mouse is hovered over it, an OH highlighter appears at the centre even when the player moves, provided that the mouse is hovered over it during moving.
    • For the player box (black box), when mouse is clicked on it, an OC highlighter appears at the centre even when the player moves or/and the mouse is not hovered over it during moving.
    • When a coloured box is left clicked and the mouse is still hovered inside that coloured box; when the player box moves into the coloured box and towards where the mouse pointer is, an OH highlighter is set on the player box (on player box layer) while the OC highlighter still remains on the coloured box. When the player box moves away from the pointer after this, then only the OC highlighter is seen on that coloured box.

    ISSUES

    • While mouse is hovered over one of the coloured box, when the player box moves into that coloured box and towards where the mouse pointer is, a bug occurred in which (provided that the mouse is within that coloured box the whole time):
      • The OH highlighter now spawns on player box layer
      • When the player box moves away from the mouse, the OH highlighter disappears, even though the mouse is still hovered over the coloured box.
      • The OH highlighter will appear again when the mouse is hovered over the overlapped section between the player box and the coloured box.

    OBJECTIVES NOT MET

    • When mouse is hovered over one of the coloured box, and when the player box moves into the coloured box and towards where the mouse pointer is, then the OH highlighter is set on the player box (on player box layer) instead of on that coloured box. When the player box moves away from the pointer after this, then the highlighter is set on that coloured box again (on coloured box layer).

    ATTACHMENT

    https://www.dropbox.com/s/a23goc6149v4p ... osave?dl=0

    I hope my description of the issue makes sense. I feel that this is a beginner's issue and therefore would love to hear how the pros do this properly. Thank you so much for your kind assistance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, so if I understand correctly:

    The events you have set up work the way you'd like to except for certain situations.

    It's seems like you have to add conditions to your events to make sure that the computer does what you want in those situations.

    I think adding an is not overlapping condition to the events pertaining the player box, would take away the unexpected results.

    Next issue would be creating a new event describing what you would like to happen in case the player box is overlapping.

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