Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / my button function

Author
Message
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 29th Dec 2003 00:21 Edited at: 29th Dec 2003 00:23
i just made a button function:

and this is how i call it:

{buttonx = screen width() - 16 and buttony = screen height - 16)

ok, now to explain what's wrong:
i made this function from this code here:

and that code works fine. but the function doesnt. it puts the image where i want it to be, but when i click on the image, it doesnt put the picture over it OR change camy#. anyone know whats wrong?

Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 29th Dec 2003 08:17
keep the paste image commands out side of the functions.

Try something like:


For the rest, I'm not sure, my brain is a bit worn out, sorry.

Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 29th Dec 2003 08:20
hrm, i dont think thats really a problem...i mean, it displays the picture fine. its just the mouse over that it doesnt get. and if i were to do it that way, i would just rather have it the way it was before...

Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 29th Dec 2003 08:36
Um, ok... Hang on a sec, I'll have one for you in a moment.


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 29th Dec 2003 08:46 Edited at: 29th Dec 2003 08:47
Actually, going over your code, it's not working because you aren't using global variables.

You must remember that anything that happens to a variabel inside a function is local to the functino and makes no difference to any variable outside the function.

Simply place GLOBAL infront of where the variable is first set up ( ie, changing_var# ) but, it must be outside of the function. That way, the variable will be updated.

I am assuming you are using the GLOBAL extended syntax provided by DarkEDIT...


and, after writing that, i realised that there is an easier way.

Change the last line to:


An when you call the function, use:


Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 29th Dec 2003 22:22 Edited at: 29th Dec 2003 22:31
yeah, but where do you learn when you always use other's code?

thanx JT, i will try that and get back and tell you how it goes.

umm...didnt work...this is what im going to do...im going to change all my buttons (8 of em) to use this function...paste the code, and you peeps can tell me whats up

i just found two errors, one i already fixed before:
function button(x, y, xsize, ysise, image_up, image_down, changing_var#, move, mousex, mousey,)
ysize had a spelling error, and i had an extra ','

JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 29th Dec 2003 22:37 Edited at: 29th Dec 2003 23:10
YES!! i got it working:
function:

call:


thanx a ton JT

heres a small preview of what iv done
http://www.geocities.com/deathlink84095/map2.zip

Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 30th Dec 2003 05:00 Edited at: 30th Dec 2003 05:01
It's cool. I'm just being a nice guy


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy

Login to post a reply

Server time is: 2025-05-22 08:41:55
Your offset time is: 2025-05-22 08:41:55