[Module] Button Class
Author |
Message |
Raknarg
|
Posted: Tue Jan 24, 2012 3:57 pm Post subject: [Module] Button Class |
|
|
Hey guys. I made a button class for a certain game, and I decided I'd share it with everyone. If you know how to use classes, it should be pretty straightforward. Here's an example program I made to go along with it. If you click the button, the number in the top right goes up by one:
Turing: |
import "Buttons2.tu"
setscreen ("offscreenonly")
var n : int := 0
var but : pointer to button
new button, but
button (but ).initialize (25, 100, 200, 175, Font.New ("Arial:30"), grey, darkgrey, white, 30, "Click me!")
loop
if button (but ).is_clicked = true then
n + = 1
end if
put n
button (but ).draw
View.UpdateArea (0, 0, maxx, maxy)
cls
end loop
|
Some notes here:
-the first four parameters are like the first four in Draw.Box
-If you make the y2 smaller than y1 or x2 smaller than x1, it wont ever detect anything
-Those three colours there are respectively fill colour, border colour and font colour
-The last number is the size of the font
-when you use the colour, the button pressed will be the colour you entered, hovering will be darker and not touching it will be darkest
Also, I forgot that when I made this topic, it's not actually a module, its a class. Sorry.
Description: |
Save the example and class in the same place |
|
Download |
Filename: |
Buttons2.tu |
Filesize: |
2.44 KB |
Downloaded: |
346 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Raknarg
|
Posted: Wed Jan 25, 2012 9:16 am Post subject: RE:[Module] Button Class |
|
|
Actlually, I forgot that this was in the wrong section entirely. Could a mod move this to submissions?
|
|
|
|
|
|
smool
|
Posted: Wed Feb 15, 2012 9:17 pm Post subject: RE:[Module] Button Class |
|
|
Looks nice, may I suggest a border around the edges? And perhaps the option of making the button a picture?
|
|
|
|
|
|
Raknarg
|
Posted: Thu Feb 16, 2012 11:32 am Post subject: RE:[Module] Button Class |
|
|
There is a border, just the color i picked makes it less distinct
and yeah, I was considering that. I'll try that.
|
|
|
|
|
|
|
|