simple button game.

MATLAB-specific help discussions.

simple button game.

Postby ragha5 » Thu Apr 19, 2012 1:53 pm

hello i am trying to create a button game. where there are n number of buttons. (i have 5). and every time you click on the button it goes.
at the moment it only works for the fist button. can you help me please.

i know its something to do with the creating of the button. in the for loop

Code: Select all
clear all, clc, close all

fh = figure;

n = 3;
x = ceil(rand(10)*2);
y = ceil(rand(10)*2);

bgh = uibuttongroup('Parent',fh,'Title',...
    'Button Game','Position',[.1 .2 .8 .6]);

for i = 1:n
    rbh1 = uicontrol(bgh,'Style','Pushbutton','String','Red',...
        'Units','normalized','Position',[rand(1) rand(1) x(1,i) y(1,i)]);



axt = axes('Parent',bgh,'Units','normalized');

axis([0.5 1 0.5 1])
axis square
axis off
Posts: 1
Joined: Thu Apr 19, 2012 1:22 pm

Return to MATLAB Help

Who is online

Users browsing this forum: No registered users and 1 guest