Hello again after awhile.
Blitz3D Forums/Blitz3D Beginners Area/Hello again after awhile.
| ||
I hate returning only to ask questions and what not, but with school and all I've had very little time to work with any programming(also been trying to learn C++ so more like little time with Blitz). Anyway, I've started a little project which will help myself or others(if I release it publicly) with such things as GUI and effects. Anyway putting all of that aside, I have one simple question...how do I make parameters in a function optional? I don't really use functions often(as you can tell), but I need them now to call the use of the GUIs and Effects. Thanks. |
| ||
You dont need anything inside a function, you can just do Function thing(), or Function thing(hi), but you dont have to use hi in the function. For GUI, I use a basic function I made up:Function mouseclick(buttonname$,buttonx,buttony) If ImagesOverlap(mouse,MouseX(),MouseY(),buttonname$,buttonx,buttony) If MouseDown(1) Return True Else Return False EndIf EndIf End Function You need mouse to be a pic (Global mouse = loadimage("mouse.bmp")) To use you would do something like: mouseclick(credits,360,370) If mouseclick(credits,360,370) = True gamecredits() EndIf Hope this helps Last edited 2010 Last edited 2010 |
| ||
To make parameters optional, give them default values:Function DoSomething(A,B=1,C$="Blah") End Function DoSomething(9) DoSomething(9,2) DoSomething(9,2, "Not Blah") |
| ||
Gabriel's answer is what you are after. |
| ||
Agreed, thanks you guys. |