Need help with setting a button's sprite when hovered over.

This forum is currently in read-only mode.
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • So basically I want to assign all my UI buttons into a single family, then handle things like hovering over them and pressing them with a single string of events. I have it set to change the animation frame if the cursor is over it or not. Problem is, if I move my mouse off one button, and on to another, the cursor is still technically over an object in my "buttons" family, so the first button stays highlighted.

    Anybody who's done something like this have some advice on the matter? I have a lot of buttons, and having to set up these events for all of them individually is impossible.

  • Just make all the buttons not highlighted, then only highlight to current button.

    Like this:

    + System: Always (every tick)
    -> Sprite: Set filter to white
    + MouseKeyboard: Mouse is over Sprite
    -> Sprite: Set filter to Blue[/code:3dc9fgtv]
  • Like I said, I was hoping there was some way I could make it family wide, so I wouldn't have to set up events for each individual button.

  • The idea is easily changed for families. Simply use a family instead of "Sprite".

  • I tried that, but then when I mouse over from one button to another, the first one stays highlighted because the cursor is still over an object in the same family.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Quick example.

    http://dl.dropbox.com/u/1646976/buttons.cap

    All the sprites are in a Family called blue.

    EDIT - you'll need 0.9.99 to open it

  • Quick example.

    http://dl.dropbox.com/u/1646976/buttons.cap

    All the sprites are in a Family called blue.

    EDIT - you'll need 0.9.99 to open it

    But, see, that still has the same problem. Since all my buttons are directly next to each other, mousing from one to another still causes both buttons to stay highlighted.

  • I tried Minor's example and when I moved the buttons in very close proximity the issue you were talking about did occur.

    I used r0j0's code though however, and it works perfectly

    The idea is easily changed for families. Simply use a family instead of "Sprite".

    I tried that, but then when I mouse over from one button to another, the first one stays highlighted because the cursor is still over an object in the same family.

    are you sure? because this worked for me, even when the buttons were literally on top of each other.

  • But, see, that still has the same problem. Since all my buttons are directly next to each other, mousing from one to another still causes both buttons to stay highlighted.

    Ah you never mentioned the buttons where right next to each other, I always work to find the easiest way to do something, then if it causes a problem I change it. Since my buttons where never placed next to each other, my .cap worked perfectly

    http://dl.dropbox.com/u/1646976/buttons.cap

    This will work when they are next to each other, miles apart or overlapping.

  • Minor you work fast, LOL

  • Quick example.

    http://dl.dropbox.com/u/1646976/buttons.cap

    All the sprites are in a Family called blue.

    EDIT - you'll need 0.9.99 to open it

    But the latest unstable release is 0.9.91, is it an SVN release?

  • > Quick example.

    >

    > <a style="color: rgb(255, 0, 0);" class="linkification-ext" href="http://dl.dropbox.com/u/1646976/buttons.cap" title="Linkification: http://dl.dropbox.com/u/1646976/buttons.cap">http://dl.dropbox.com/u/1646976/buttons.cap</a>

    >

    > All the sprites are in a Family called blue.

    >

    > EDIT - you'll need 0.9.99 to open it

    >

    But the latest unstable release is 0.9.91, is it an SVN release?

    No it's a special "Minor Only" release. Man it's great making a game in Construct for iphone, Android, Flash, Linux, Mac, Amstrad CPC, Nokia Ngage, Spectrum, 3DO and Atari 2600.

    Just kidding idiot me put the fullstop in the wrong place

    It was made in 0.99.9

  • Wow, that's a really clever solution. I would never have thought to reset the frame every step like that.

    Thanks!

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