Simple Button Class
Author |
Message |
Degensquared
|
|
|
|
|
Sponsor Sponsor
|
|
|
SNIPERDUDE
|
Posted: Thu Dec 20, 2007 6:45 pm Post subject: RE:Simple Button Class |
|
|
wow, Button/GUI classes seem to be growing popular in subject.
Good work!
|
|
|
|
|
|
Degensquared
|
Posted: Thu Dec 20, 2007 7:11 pm Post subject: RE:Simple Button Class |
|
|
Thanks I'm planning on adding custom sizes and fonts for the labels
|
|
|
|
|
|
Lawlly
|
Posted: Thu Dec 20, 2007 7:15 pm Post subject: Re: Simple Button Class |
|
|
It looks useful to me but I don't understand how I can use it.
I'm thinking of creating 3 buttons for a game I'm making. When you click it it selects a map. How can I use this for that? Of course if I were to use it, I'd note it as borrowed code.
|
|
|
|
|
|
Degensquared
|
Posted: Thu Dec 20, 2007 9:19 pm Post subject: Re: Simple Button Class |
|
|
Well, if you look at the example program, it should be kind of clear, but if not here you go:
You would need to set up 3 variables, each a pointer to the button class.
and the variables to check if the buttons have been clicked
create the objects using the new command,
initialize each of them.
check if they were clicked and are now not clicked
draw the buttons.
code: |
var button1,button2,button3 : ^button
var lastclicked, clicked : boolean
new button1
new button2
new button3
button1 -> initialize (x1,y1,x2,y2, do you want depression animation, color of the button)
...
button3 ...
button1 -> clicked (clicked, lastclicked)
if lastclicked and not clicked then
do whatever
end if
...
button3 ...
button1 -> draw
...
button3 -> draw
|
Loop that (make sure you use offscreenonly and View.Update!)
and it should work
|
|
|
|
|
|
SNIPERDUDE
|
Posted: Sun Dec 23, 2007 9:47 pm Post subject: Re: Simple Button Class |
|
|
do note that if you made your programme so the user or programmer only had to call one line, it would make it easier.
for example:
code: |
loop
drawButton (any inside parameters such as X, Y, colour, text, procedure to be executed when pressed)
View.Update
exit when hasch
end loop
|
|
|
|
|
|
|
Degensquared
|
Posted: Thu Dec 27, 2007 11:04 pm Post subject: RE:Simple Button Class |
|
|
hmm... well I personally like to split my programs into, input, calculations, and output. so that's why I split the draw and clicked commands, but I do think I could have labels included in the initialization.
|
|
|
|
|
|
|
|