Invisible entity can still be clicked?

Discussion and feedback on Construct 2

Post » Mon Aug 27, 2012 4:36 am

Hi all

I was playing around with C2 and noticed that when an entity is set to invisible, it's still possible to interact with it.

Sample code:
https://dl.dropbox.com/u/20830426/VisiblityQuirk.capx

Is this intended behaviour? If an entity is invisible, should I still be able to click it?

If this is intended behaviour, are there any good alternatives to hiding an entity to avoid a player being able to click it? I figured a quick dirty hack is to set the position to x9999/y9999, but I'm sure there is a better option :)

Cheers!
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Mon Aug 27, 2012 4:46 am

This is intended - you may have cases where you want to interact with an invisible object. Just check if your object is visible in the click event if you want to avoid interacting with it when it's not.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Mon Aug 27, 2012 7:47 pm

Ah ok, no worries then.

"Just check if your object is visible in the click event "

Unfortunately in my case the actions of the menu fire once the menu is hidden :) Basically clicking the menu fires of a number in an Enum (equivalent). I then have (the equivalent of) a case statement saying "if 1 was clicked, do this action". By the time it hits that line though the menu has already been hidden, so the view state can off but the event still needs to fire.

It would be nice if there was a toggle state to say "Ignore Input" or similar. It would make the events a bit cleaner than having "if visible/not visible' scattered over the place.

Thanks for the feedback :)
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Mon Aug 27, 2012 7:51 pm

use the "wait(x amount of time)" action, followed by your events, to make them happen after the menu was closed. Just make sure to time it right.
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Post » Mon Aug 27, 2012 7:54 pm

mmm, I could give that a shot. I usually try and avoid race conditions, but since this is just a prototype it might be fine for now.

Cheers Fimbul.
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Mon Aug 27, 2012 8:03 pm

For things like menu i used make a global variable called "menu" and do something like this

+System: menu = "visible"
   + All actions for menu

+System: menu = "not_visible"
   + All actions for game

This will make sure that all object for menu are only accessible when global variable = visible - all interactions with buttons, sprite visibility etc...
It's quite easy and fast to setup.
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 11 guests