View Single Post
Old 10-10-2013, 11:49 PM   #51
Hubi
Human being with feelings
 
Join Date: Oct 2010
Posts: 83
Default

A simple button maker function:

Code:
function button(state x1 y1 x2 y2 r g b)
  (
  gfx_x = x1;
  gfx_y = y1;
  gfx_r =r;gfx_b=b;gfx_g=g;
  (mouse_x > x1 && mouse_x < x1+x2 && mouse_y > y1 && mouse_y < y1+y2) ? (
    gfx_r =r+0.05;gfx_b=b+0.05;gfx_g=g+0.05; 
    mouse_cap == 1 ? (
      state = 1;
      gfx_r =r+0.2;gfx_b=b+0.2;gfx_g=g+0.2;
      );  
    ) : (
    state = 0; 
  ); 
  gfx_rectto(gfx_x+x2,gfx_y+y2); 
  state;
  );
Code:
button_clicked = button(state,20,20,40,20,0.6,0.6,0.6);
state returns "1" if the button is clicked, otherwise it is "0"
x1 and y1 are the position of the left top corner
x2 and y2 are the size of the button
r,g,b color


it shows if the mouse hovers over the button and if it is clicked

regards
Hubi
Hubi is offline   Reply With Quote