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

For questions about using Classic.

Post » Mon Jul 12, 2010 2:44 am

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.
B
4
G
3
Posts: 31
Reputation: 964

Post » Mon Jul 12, 2010 4:13 am

Just make all the buttons not highlighted, then only highlight to current button.
Like this:
[code:3dc9fgtv]+ System: Always (every tick)
-> Sprite: Set filter to white
+ MouseKeyboard: Mouse is over Sprite
-> Sprite: Set filter to Blue[/code:3dc9fgtv]
B
79
S
24
G
54
Posts: 4,743
Reputation: 40,749

Post » Mon Jul 12, 2010 4:32 am

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.
B
4
G
3
Posts: 31
Reputation: 964

Post » Mon Jul 12, 2010 6:17 am

The idea is easily changed for families. Simply use a family instead of "Sprite".
B
79
S
24
G
54
Posts: 4,743
Reputation: 40,749

Post » Wed Jul 14, 2010 6:24 am

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.
B
4
G
3
Posts: 31
Reputation: 964

Post » Wed Jul 14, 2010 8:14 am

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 :)
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Thu Jul 15, 2010 2:55 am

[quote="Minor":2o10eywz]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 :)[/quote:2o10eywz]

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.
B
4
G
3
Posts: 31
Reputation: 964

Post » Thu Jul 15, 2010 3:41 am

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

[quote="R0J0hound":b9c5di43]The idea is easily changed for families. Simply use a family instead of "Sprite".[/quote:b9c5di43]

[quote="Pythagoras":b9c5di43]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.[/quote:b9c5di43]

are you sure? because this worked for me, even when the buttons were literally on top of each other.
B
15
S
2
G
3
Posts: 50
Reputation: 1,863

Post » Thu Jul 15, 2010 8:37 am

[quote="Pythagoras":2oyahrun]
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.[/quote:2oyahrun]

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.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Thu Jul 15, 2010 3:41 pm

Minor you work fast, LOL
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests