Disable image click when invisible

0 favourites
From the Asset Store
High quality sound effect pack, in the following categories: Simple, negative, pozitive
  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In your event 'on object clicked', just add a variable or visibility comparison condition.

  • 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.

  • 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.

  • 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 =/

  • 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 :)

  • 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)

  • 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?

  • 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 ;)

  • 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...

  • This is what I use. Does this help?

    <img src="http://img593.imageshack.us/img593/598/support012.png" border="0" />

  • Tekniko,

    I had the same question, thank you for the hint.

    Works perfectly.

    Cheers

  • Tekniko

    Add me to the list of people your elegant solution helped! Thanks!

  • The image link is broken for the solution. Can anyone help me find it or maybe type the solution out?

    Tekniko

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