Sprite Opacity change on mouse hover

0 favourites
  • 15 posts
From the Asset Store
Create your game with this complete pack of images and animations!
  • Hey everyone. I'm kind of stuck, I have a menu setup and all the buttons are at 50 opacity. I want to set it so whenever the mouse is over a button it changes to 100 opacity. What I'm doing does the job but occasionally if I swipe the mouse over the column of buttons it leaves a trail of them set to 100. What I have is:

    condition: mouse is over button, action: Set button opacity to 100

    else: Set button opacity to 50

    What am I missing?

    Your help would be immensely appreciated. :)

  • probably should add that each button is the same image. I separated out the buttons by declaring an instance variable for each. Any ideas guys and gals?

  • Take a look at this thread and see if it's the same problem:

    http://www.scirra.com/forum/mouse-over-problem_topic54028.html?KW=

  • Solution-

    Capx

    Hope this helps

    Edit-

    Xavier link (above) to Ashley's solution is better!

    <img src="smileys/smiley9.gif" border="0" align="middle">

  • chrisbrobs, Xavier

    Thanks guys,

    OMG there's an invert switch. Roflmao, I've never seen that before. That makes so many things soooo much easier. I couldn't seem to find an answer so what I ended up doing was to create a sub group set to disabled. In the group I had it flip through every instance and set the opacity accordingly. Then I called it once the cursor was over an instance. This appears to be much more fluid. Thanks again. :)

  • chrisbrobs, Xavier

    Scratch that,

    Did the same thing. It does highlight the right button in preview but once I upload it occasionally leaves a bunch lit up. I guess I'll switch back to the way I had it. Not very pretty but never gives a false positive on upload.

  • buttonopacity.capx

    Works fine here, with capx and after uploading

  • Heres what I've done that seems to work:

    <img src="https://dl.dropbox.com/u/77974757/Capture6.PNG" border="0">

    Try it out at:

    http://apps.facebook.com/relicsofyore

    Anyone else have a more basic solution?

    • remove that group
    • above event 18 put an action:

    every tick set Button opacity to 50

    should work

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • shinkan, won't that cause a fluttering effect as it also sets the highlighted sprite back to 50 as its also highlighting the button? Thank you all for the help btw. :)

  • see my file four posts above, working as it should

    Edit: well now on the previous page ;)

  • shinkan

    tried that and worked like a charm. :) Although I'm still confused why its not fluttering, thanks for the help. :)

  • It's how the event's work

    Everything is here: ecents in the manual

    It's a lot of text and people are too lazy to read but everything is explained there. ;)

  • shinkan, won't that cause a fluttering effect as it also sets the highlighted sprite back to 50 as its also highlighting the button? Thank you all for the help btw. :)

    To obtain a flickering effect, you would have to have some switch between the opacity over several ticks.

    But the actual code is processed each tick. Each tick, the sprite's opacity is either 50 or 100, it's not switching from 50 to 100 "in the same tick". And even if it was, it's too quick for the brain to even notice.

    As Shinkan said, this is how events work. The screen is rendered only once all events have been tested/executed, and so a single image per tick is rendered out of it.

    Considering that C2 does the job of not re-rendering something that hasn't been moved/accessed to, it has even less reasons to flicker.

  • THank you for this post. Went to look for the invert. WOW. Thanks, what a difference that will make.

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