Jump to content


Photo

RADIO BUTTON


  • Please log in to reply
8 replies to this topic

#1 gameside

gameside

    GMC Member

  • GMC Member
  • 70 posts

Posted 04 March 2012 - 09:08 AM

hi there! :smile:
i making radio button for my project and i want to know two things (1) is it possible to make radio button using my own sprite and also :huh: (2) is it possible to make on object as radio box and create 3 instance in the room so each one can do different action? :huh:
i search on the forum and google but cant find one. :sad:
please help me!!! :confused:
  • 0

#2 wnsrn3436

wnsrn3436

    GMC Member

  • GMC Member
  • 132 posts
  • Version:GM8

Posted 04 March 2012 - 09:18 AM

Posted Image

(2) In the case. ;)
  • 0

#3 gameside

gameside

    GMC Member

  • GMC Member
  • 70 posts

Posted 04 March 2012 - 09:41 AM

Posted Image

(2) In the case. ;)


thanks wnsrn3436 and how about the first case :mellow:
can anyone help me :blush:
  • 0

#4 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5379 posts
  • Version:GM:Studio

Posted 04 March 2012 - 09:51 AM

tempting to just answer a plain "yes" on 1 x3 .. but alright:

create:
image_speed=0;

on click:
image_index=!image_index;

that's pretty mutch all a radio button need.. and a sprite with a subimage .. and you are done
  • 0

#5 gameside

gameside

    GMC Member

  • GMC Member
  • 70 posts

Posted 04 March 2012 - 10:23 AM

tempting to just answer a plain "yes" on 1 x3 .. but alright:

create:
image_speed=0;

on click:
image_index=!image_index;

that's pretty mutch all a radio button need.. and a sprite with a subimage .. and you are done


it work good for one instance, but for more then two instance it work like check box not radio button, because you can select more then one option. how make that :unsure:

Edited by gameside, 04 March 2012 - 10:25 AM.

  • 0

#6 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5379 posts
  • Version:GM:Studio

Posted 04 March 2012 - 10:32 AM

oh, I'm mixing up those two >< sorry

on click:
with(object_index)image_index=0; // force the others to go to normal
image_index=!image_index; // while you change the clicked one

  • 0

#7 gameside

gameside

    GMC Member

  • GMC Member
  • 70 posts

Posted 04 March 2012 - 10:44 AM

Thanks FoxInABox it work great :thumbsup: your genus man!!!
thanks again, :thanks: but let me ask anther question that how to add more then on action for them from one object
  • 0

#8 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5379 posts
  • Version:GM:Studio

Posted 04 March 2012 - 11:47 AM

http://solidfiles.co...b39c88f3af/get/

ok I guess you want to have diffrent set of buttons aswell, so I made the example:

I placed 1 button, then went into creation code and gave it a nr, then made 3 more buttons that I wanted to have the same number ..

I made a code so that the first button will give its number to all the buttons I make afterwards (to save some work ^^)

then I made a new button with a diffrent nr and some more after that:

I also made it so that the buttons are given a number for what index they are under that number .. so the first 4 got
nr 0 and index 0 1 2 3 .. while the 4 next got
nr 1 and index 0 1 2 3

and after they have assigned themself a number .. then they try and add a text from the list you make in the create event.. hope it makes some sence ^^;;

take a look, there are some comments aswell.

BUT

just to keep it stupid simple:
- make some buttons
- give them the a variable in creation code to tell them they are in the same set/group
set=1;
text='test';
- make some more buttons, and do the same .. just a diffrent number
set=2;
text='test';

now then, for the radio button, click event:
with(object_index)if set=other.set image_index=0;
image_index=!image_index;
room start event:
image_speed=0; // to stop flickering
image_index=1; // select this radio button

with(object_index)         // tell all buttons
  if set=other.set         // if it is another one from the same set
    if id<other.id {       // but it got smaller id ( was placed before this one )
      other.image_index=0; // then remove selection
      break;               // if so then break out of this code
    }
draw event:
draw_sprite(sprite_index,image_index,x,y)
draw_text(x+16,y,text)

..
and that's about it, but to check what button is selected:
var i;
i=0;
with(OBJ)if set=# if image_index break else i+=1; // you have to change OBJ and # to the set you want

if i=0 show_message('the 1st radio button was selected')
if i=1 show_message('the 2nd radio button was selected')

and that's about how simple as I get it ..

Edited by FoxInABox, 04 March 2012 - 12:21 PM.

  • 0

#9 gameside

gameside

    GMC Member

  • GMC Member
  • 70 posts

Posted 04 March 2012 - 12:34 PM

http://solidfiles.com/d/b39c88f3af/get/

ok I guess you want to have diffrent set of buttons aswell, so I made the example:

I placed 1 button, then went into creation code and gave it a nr, then made 3 more buttons that I wanted to have the same number ..

I made a code so that the first button will give its number to all the buttons I make afterwards (to save some work ^^)

then I made a new button with a diffrent nr and some more after that:

I also made it so that the buttons are given a number for what index they are under that number .. so the first 4 got
nr 0 and index 0 1 2 3 .. while the 4 next got
nr 1 and index 0 1 2 3

and after they have assigned themself a number .. then they try and add a text from the list you make in the create event.. hope it makes some sence ^^;;

take a look, there are some comments aswell.

BUT

just to keep it stupid simple:
- make some buttons
- give them the a variable in creation code to tell them they are in the same set/group

set=1;
text='test';
- make some more buttons, and do the same .. just a diffrent number
set=2;
text='test';

now then, for the radio button, click event:
with(object_index)if set=other.set image_index=0;
image_index=!image_index;
room start event:
image_speed=0; // to stop flickering
image_index=1; // select this radio button

with(object_index)         // tell all buttons
  if set=other.set         // if it is another one from the same set
    if id<other.id {       // but it got smaller id ( was placed before this one )
      other.image_index=0; // then remove selection
      break;               // if so then break out of this code
    }
draw event:
draw_sprite(sprite_index,image_index,x,y)
draw_text(x+16,y,text)

..
and that's about it, but to check what button is selected:
var i;
i=0;
with(OBJ)if set=# if image_index break else i+=1; // you have to change OBJ and # to the set you want

if i=0 show_message('the 1st radio button was selected')
if i=1 show_message('the 2nd radio button was selected')

and that's about how simple as I get it ..


thanks! :biggrin: man that is what i wanted GREAT WORK! :thumbsup: :thumbsup: :thumbsup: FoxInABox
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users