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
i search on the forum and google but cant find one.
please help me!!!
Posted 04 March 2012 - 09:08 AM
Posted 04 March 2012 - 09:18 AM

Posted 04 March 2012 - 09:41 AM
(2) In the case.
Posted 04 March 2012 - 09:51 AM
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
Edited by gameside, 04 March 2012 - 10:25 AM.
Posted 04 March 2012 - 10:32 AM
with(object_index)image_index=0; // force the others to go to normal image_index=!image_index; // while you change the clicked one
Posted 04 March 2012 - 10:44 AM
Posted 04 March 2012 - 11:47 AM
set=1; text='test';- make some more buttons, and do the same .. just a diffrent number
set=2; text='test';
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)
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')Edited by FoxInABox, 04 March 2012 - 12:21 PM.
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/groupset=1; text='test';- make some more buttons, and do the same .. just a diffrent numberset=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 ..
0 members, 0 guests, 0 anonymous users