Disable image click when invisible

Get help using Construct 2

Post » Thu Jan 17, 2013 2:18 am

Hi guys,

I'm using sprites for my buttons, and I'd like to know if there's any way to disable the clicking on a sprite anyhow.

I've tried to disable its collision, but I guess that only works for one object touching another object.

It's actually inside a group so its actions/events don't run unless I activate the group (which I do when the layer the sprite is on is visible).

Thanks,

Miyavi.
B
6
Posts: 54
Reputation: 808

Post » Thu Jan 17, 2013 2:23 am

In your event 'on object clicked', just add a variable or visibility comparison condition.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Thu Jan 17, 2013 2:25 am

The group is already disabled on the start of the layout, so I think that's not the matter.

Even although it's disabled, if I have for example, a gotoLevel sprite, and click where the disabled sprite is meant to be, it blocks me from clicking on the gotoLevel sprite.
B
6
Posts: 54
Reputation: 808

Post » Thu Jan 17, 2013 2:34 am

Yeah, I was guessing right.
After implementing that, it stills blocks my clicking path.

I guess I could send it to a different layer number, and recover it back, but I was guessing if there was a different way.
B
6
Posts: 54
Reputation: 808

Post » Sun Mar 24, 2013 4:48 pm

I got the same problem. The different layer number doesn't help because your sprites are still clickable thorugh the layers even if they are invisible.

It seems that you really have to create a whole new layout for each status OR try it with this comparison method (I'm gonna try that now). That's kind of annoying =/Valnuss2013-03-24 16:50:05
B
3
Posts: 4
Reputation: 283

Post » Sun Mar 24, 2013 4:56 pm

There are several ways you can do it.

1. Which i think is the best way is to destroy the buttons when you are not using them. And create them when needed. Add them in a container if possible, even though having to align them after create is a bit time consuming. That way you know they are not active when not needed.

2. You can move the buttons off screen, so if button not needed set position to -1000,-1000 and when needed you just set them back to there original placement. You can add two variables, "Original_X" and "Original_Y" and set these values in the layout before hand.

However would recommend the first option :)
B
40
S
10
G
2
Posts: 1,148
Reputation: 6,495

Post » Sun Mar 24, 2013 5:12 pm

Sorry, but that doesnt work ;)

I tried it. If I move the buttons out of the layout and say that they shall appear at the former coordinates in the layout they will be clickable like they never vanished. Yeah, really. If you dont beleive me, try it :)

In my case there's a big sprite in the center, overlapping all others.
2 Buttons in the background, 1 in the upper half and the other one in the lower. I can click "through" the overlapping visible sprite and activate at the same moment the button behind (and yeah, like I said, EVEN in the moment when they reappear with the click they get activated..maybe I need some time trigger to let them appear 0.001 seconds after I clicked)

I also tried the option with destroying and spawning and also creating but it doesn't work the way you expect. Same problem like above.

Edit: I try to do it with a variable but it still doesn't work the way it should -.- Same problems like in the other cases. There are clickable in the moment they spawn. You need a timeout, there is no other way to solve this problem (besides a new layout)Valnuss2013-03-24 18:50:43
B
3
Posts: 4
Reputation: 283

Post » Sun Mar 24, 2013 5:54 pm

Cant you just add a variable Clickable to the buttons, and if its false you cant and if they are true then click?

"The image point is set to 0. Maybe because he doesn't know WHERE to spawn the objects."

It should spawn at the origin of the object spawning it, if nothing is changed. You sure it spawns on the correct layer, and that its on top of the layer?
B
40
S
10
G
2
Posts: 1,148
Reputation: 6,495

Post » Sun Mar 24, 2013 6:00 pm

Yeah, I edited my post again because I tried it also with "create object". The positions are right and the sprite spawns there BUT it is still clickable in THE MOMENT it is spawned - in this case the moment I click at the upper half of the overlapping sprite.

And yeah, I tried it with the variable. The problem here isn't the possibility to put an object out of sight and bringt it back. There are many ways to do it. The problem lies in the time/moment this object is sent back. I tell you, try it by yourself. It won't work.


Added a wait action for 0.0001 seconds and it's fine, just as expected ;)Valnuss2013-03-24 18:51:28
B
3
Posts: 4
Reputation: 283

Post » Sat May 11, 2013 8:37 pm

@Valnuss teach me how to set the image point on Construct when i set to spawn another object please.

I have 3 buttons I need to insert on the program after choose one option and them appear in a randomly order if I keep the image point 0.

Update: Forget I found it on the Edit Image.
Still I Have the same problem.. so the only way.. is to bring them back to the layout on defined positions? each button sprite.. so if I have 50 buttons.. I gotta define all of them in x,y position?

Edit: So I made some experiences by myself.
This is the problem > https://mega.co.nz/#!xYgU2a7Q
Here is the solution > https://mega.co.nz/#!tN4GARaI

Suggestions for an easier way are accepted...DarkevilPT2013-05-11 23:53:24
B
5
S
1
Posts: 16
Reputation: 957

Next

Return to How do I....?

Who is online

Users browsing this forum: LeFuji and 22 guests