0 Favourites

Make buttons randomly lighten

  • Hello dudes,

    After lots of tutorials i decided to get a try with Construct 2.

    I wanted to make a simple kinda platform/puzzle game and i have a problem.

    In my game you need to pop bubbles of precise color.

    If you do so you have points and if you don't you lose them.

    The color is indicated by 4 indicators that are set invisible in the beginning.

    The thing is that i can't find a way to make them become "visible" one by one and randomly without lightening all of them.

    Can you help me?

  • Would this work?

    every x seconds

    -pick all buttons - set invisible

    -pick random button instance - set visible

  • I've already tried but the problem is that for instance easch 3 seconds multiple lights will lighten.

    I need just one by one, randomly.

    I'm sure there's a very stupid trick but still.. Can't find it

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I need something like. When one is visible the others are invisible. But still this one must be random and alone

  • Did you use the system pick random instance as I suggested?

    That should only pick one.

    You could also use a choose() expression setting a variable and set the light depending on the variable.

  • Yep i have tried. But still the same issue.

    I will try to be more clear.

    I have 4 objects, thus 4 knobs(red, blue, green, yellow) that are initially set invisible.

    The idea is that each 3 to 6 seconds one of them will become visible for about 3 seconds and then another one will randomly do the same.

    But when I write 4 conditions "-pick random button instance - set visible" for each of them they shine all at the same time.

    I even tried to put an or between the 4 conditions, same result.

    And then there is another issue, i would like to turn them down after maximum 3 seconds of activity. So i've made a sub event and put 2 conditions in it (if button visible, compare time >3 seconds---->set invisible)...now it's all black lol

    There must be a thing i don't get, it's very frustrating

  • Here's a solution.

    Create one button and then add an animation frame for each colour you want the button to display.

    Set ani speed to 0

    On your layout you can then manually select the frame corresponding to the colour you want to display.

    I've already made it sound more complicated than it is. <img src="smileys/smiley4.gif" border="0" align="middle" />

    Here's a pic showing the important stuff.

    I've set it to change every second, change that to 3,6 whatever you want for a slower rate of change.

    Ref your second point for effect you could add the "Fade" behaviour to the button and set it to fade out and destroy after the timeout period of your choice. More aesthetic way of presenting the game.

    <img src="http://s27.postimg.org/q6pplzimr/solution.jpg" border="0" />

  • Sorry the img was resized.

    <img src="http://s29.postimg.org/8xakg0j3b/solution.jpg" border="0" />

  • Here's how to set the "fade", you will need to add the fade behaviour to the button first.

    This example means the button will fade in over 1 second, stay 100% opaque for 2 secs then fade out and destroy over 1 second = 4 seconds total.

    So if you changed the 1 sec to 6 secs in my first example you would get 4 seconds to press the button before it disappeared then a two second pause before the next one fades in.

    (More than Simon gave you) <img src="smileys/smiley36.gif" border="0" align="middle" />

  • Doh!!

    <img src="http://s27.postimg.org/5lfj7tqfn/fade.jpg" border="0" />

  • Sorry that needed new code.

    believe it or not the problem that you had can be solved in as few lines as this:

    (Set destroy to "No" on Fade behaviour)

    <img src="http://s2.postimg.org/m42oon26x/Capture6.jpg" border="0" />

  • Thank you Bertie Booster <img src="smileys/smiley1.gif" border="0" align="middle" />

    Your advice didn't work as i wanted (the blue was always on but other buttons didn't pop) but at least they weren't all popping at the same time.

    So i inserted a "choose between frames" and it worked perfectly.

    Thank you for everyone :)

    PS: By the way why can't i post images and urls in the topic but you yes?

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