How do I highlight objects by mouse hover and mouse click

Just started using Construct 2? Post your questions here

Post » Sun Apr 12, 2015 4:26 am

Hi. I have tried to do this myself and found one issue which I cannot solve :| . 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

Image

OBJECTIVES MET

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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

  1. 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):
    1. The OH highlighter now spawns on player box layer
    2. When the player box moves away from the mouse, the OH highlighter disappears, even though the mouse is still hovered over the coloured box.
    3. 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

  1. 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.
B
7
S
2
Posts: 3
Reputation: 550

Post » Sun Apr 12, 2015 10:36 am

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.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest