How do I create a radiobutton

Get help using Construct 2

Post » Fri Mar 28, 2014 4:35 am

i need to create a radio button, because with checkbox option of the button plugin a can check more than 1 check box and i need only can check 1 at time.

thank you for your help guys. :)
Carlo Andrei Mercado

Animator, illustrator, concept artist, special effects for games.

[email protected]

http://f-fman.wix.com/portfolio-ffman22

http://ffman22.deviantart.com/



tutorials:



https://www.scirra.com/tutorials/950/dynamic-mini-map dynamic-mini-map tutorial



https://www.scirra.com/tutorials/9479/p ... ing-damage falling damage platform tutorial



originally published by ffman22
B
62
S
19
G
4
Posts: 340
Reputation: 6,606

Post » Fri Mar 28, 2014 5:45 am

Hi, if you want to use the button object for your radio buttons, you can do this

Create three buttons: button1, button2, button3, set the type for all buttons to checkbox.

Event\Actions:
button1 - On clicked >
    button2 Set unchecked
    button3 Set unchecked

button2 - On clicked >
    button1 Set unchecked
    button3 Set unchecked

button3 - On clicked >
    button1 Set unchecked
    button2 Set unchecked

Or you could do it with sprites. . . .
If it can be done, someone on the web will show you how to do it!

CDASI Games Mentality Break Splat-a-bug FlapFleet Challenge
B
35
S
13
G
7
Posts: 363
Reputation: 7,283

Post » Fri Mar 28, 2014 8:24 am

@michael thank you, but if i have a lot of checkbox like 100 o more?
Carlo Andrei Mercado

Animator, illustrator, concept artist, special effects for games.

[email protected]

http://f-fman.wix.com/portfolio-ffman22

http://ffman22.deviantart.com/



tutorials:



https://www.scirra.com/tutorials/950/dynamic-mini-map dynamic-mini-map tutorial



https://www.scirra.com/tutorials/9479/p ... ing-damage falling damage platform tutorial



originally published by ffman22
B
62
S
19
G
4
Posts: 340
Reputation: 6,606

Post » Fri Mar 28, 2014 11:30 am

I have some radio-style buttons in my current project. The absolute easiest way is, in psuedo-code

function onButtonClick
- all buttons Set unchecked

button0 -> onClick
- Function.Call("onButtonClick")
- button0 set checked
- radio variable - set 0

button1 -> onClick
- Function.Call("onButtonClick")
- button1 set checked
- radio variable - set 1

etc
B
9
S
3
Posts: 37
Reputation: 749

Post » Fri Mar 28, 2014 12:47 pm

ffman22 wrote:@michael thank you, but if i have a lot of checkbox like 100 o more?


I always use images for buttons - just my preference, so for a bit of fun I created an example using images for the radio buttons, based on what I do in my apps.

However I don't have that many options in my games so it may not be what you are after - but it might give you some ideas to go on.

Note the example is built using R165.
You do not have the required permissions to view the files attached to this post.
If it can be done, someone on the web will show you how to do it!

CDASI Games Mentality Break Splat-a-bug FlapFleet Challenge
B
35
S
13
G
7
Posts: 363
Reputation: 7,283

Post » Fri Mar 28, 2014 5:35 pm

nusbaumc wrote:I have some radio-style buttons in my current project. The absolute easiest way is, in psuedo-code

function onButtonClick
- all buttons Set unchecked

button0 -> onClick
- Function.Call("onButtonClick")
- button0 set checked
- radio variable - set 0

button1 -> onClick
- Function.Call("onButtonClick")
- button1 set checked
- radio variable - set 1

etc

@nusbaumc maybe this work with a family ??
example
function onButtonClick parameter 0 (id)
for -> buttons instance count
button id =/= id
-Set unchecked

buttons -> onClick
- Function.Call("onButtonClick(buttons.id)")
- radio variable - set 1
Carlo Andrei Mercado

Animator, illustrator, concept artist, special effects for games.

[email protected]

http://f-fman.wix.com/portfolio-ffman22

http://ffman22.deviantart.com/



tutorials:



https://www.scirra.com/tutorials/950/dynamic-mini-map dynamic-mini-map tutorial



https://www.scirra.com/tutorials/9479/p ... ing-damage falling damage platform tutorial



originally published by ffman22
B
62
S
19
G
4
Posts: 340
Reputation: 6,606


Return to How do I....?

Who is online

Users browsing this forum: ditocruz, RalleRoyal and 28 guests