How do I stop mouse over from affecting adjecent instances?

0 favourites
  • 12 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • I am creating a memory card game with a grid of 6x6 cards.

    I have created a card object with an event to show frame one when the cursor is over the card. An else statement resets the frame to zero when cursor is no longer over the card.

    The issue I am having is since all my cards touch, they are not being reset to frame zero, even if my mouse has moved to a different card instance. For instance, I move my mouse over the top-left card and it changes to frame one, when I move my mouse to the card next to it that card also changes to frame one but the original card does not change back to frame zero.

    The cards only set back to frame zero if I move the cursor into an area where the card object does not exist.

    Any help is appreciated.

  • add a for each card

  • Sorry I'm very new to this.

    The events I have are:

    if mouse cursor is over card, set card animation frame to 1.

    else set card animation frame to 0.

    I tried adding a for each to the mouse event but it didn't work.

    Is that what you meant?

    If the cards are touching they do not reset to frame 0 until I move the mouse away from all the cards.

    Thanks

  • if mouse courser is over card

    for each card

    set animation frame to 1

    it´s much easier to explain if you post your project file or at least a screenshot.

  • I'm not sure how to upload the c3p file but here are some screenshots.

    See how the two top cards are outlined white. I only want the card my mouse is over to be outlined white.

    Thanks

  • Hmm so your cards overlap, try adding another condition: Pick top instance

  • Same result :(

  • hmm try an else at the second condition? otherwise pls share the c3p somehow. Dropbox, google drive, anything works...

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Trying an else statement for the second condition gives a validation error.

    Here is a link: 1drv.ms/f/s!Al5lE7D8HY4eabddQrq14LzdNQ0

    Thanks

  • Quite interesting case, it looks a bit hacky but it works. Try this:

  • if you want a fail proof solution you need to use uid picking or set a variable on the cards (if uids are confusing making a variable and setting a number is just a

    that is it.. now u have a ascending number for each card in the screen already existing at the start of layout)... that being said as now thinking the cards are the same sprite but duplicated.

    so if the cards are all the same sprite and you want to uid pick you do the following

    then

    then you have two separated conditions as the mouse one not under the mouse but separated entirely different things

    1st will be

    2nd one would be

    (if you dont know what inverted is ... you right click the condition and there is a invert action that basically acts like else.... but more secure then else... cause else means anything but that action .. that can mean a glitch a bug etc that you might not want to trigger it ... while reverse means only uid not matching that variable in this case.)

    then you need a hover out of cards reset for the picking so the last card picked card won't stick to changed.

    and that is basically

    and that is it... easy 5 conditions.

    here is a Construct 2 example just import it in C3

  • IT WORKS!

    Thank you both so much.

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