How do I use Mouse over object / On object clicked together?

Just started using Construct 2? Post your questions here

Post » Tue Oct 06, 2015 9:21 am

Hi all,

Testing a scenario where I have 3 mouse interaction states for an image, using animation frames, instead of the button object.

Idle state: working
Inverted Mouse: Cursor is over object, set animation frame to 0.

Hover state: working
used Mouse: Cursor is over object, set animation frame to 1.

Clicked state: not working
used Mouse: On object clicked, set animation frame to 2.

The problem seems to arise because the clicked state does not override the hover state (if you can click the image, your cursor is definitely over the object). So hover state is always active in these 2 states. If I do not use the hover state, then I can get the idle and click states working together.

https://www.dropbox.com/s/ugwgv7o6tk5kqer/mouseclick.capx?dl=0

Or should I be doing things in a different way? Thanks in advance!
B
4
Posts: 3
Reputation: 231

Post » Tue Oct 06, 2015 9:35 am

whazzup wrote:.

The problem seems to arise because the clicked state does not override the hover state (if you can click the image, your cursor is definitely over the object). So hover state is always active in these 2 states. If I do not use the hover state, then I can get the idle and click states working together.


It's the other way around. All events are in one big game-loop and if you click your image the state will be immidetly in the next tick overridden by you hover-event. The click-event triggers but you don' see it. :)

Put a 'trigger once' to your 'cursor is over'-event. But be careful you have to put it under your 'cursor is over'-event (not a subevent) otherwise you only trigger once the animation setting to 1 not the hover-event.
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Tue Oct 06, 2015 9:43 am

MAGICAL! Works now, thanks! I've updated the capx. It's a simple thing but not very obvious if you're new (like me), hope it helps someone.

https://www.dropbox.com/s/ugwgv7o6tk5kqer/mouseclick.capx?dl=0
B
4
Posts: 3
Reputation: 231


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests