
-----------------------------------
Sam_sam
Fri Dec 19, 2008 8:44 pm

How to make button help!?!
-----------------------------------
Hey,
I am no good at this.. so don't expect much. 
I am in gr.9 doing a grade ten course.. crazy lol
Now.. I am making a title page which is the entrance to
a store.. and I want to make a button that will lead
to the rest of the project.. however.. IT WON'T WORK!... I put 
the rest of my code as a comment except for the button and it works
but when I use my whole code.. it won't work.. 
I would really appreciate it if you could tell me why and how to fix it!
THANKS
P.S- I am trying to get the button with the Welcome screen.. that is possible right :opps: ?

Code:


% loop
%  delay (1000)
%  cls
%  var x,y,buttonnumber,buttonupdown:int
%  buttonwait("down",x,y,buttonnumber,buttonupdown)
%  put x
%  put y
%  end loop


%------------------------------------------------------------------------------
var fonts : int
var font : int
setscreen ("graphics")
colorback (yellow)
cls
fonts := Font.New ("Papyrus:30:italic")
assert fonts > 0
font := Font.New ("Arial:12:italic")
assert font > 0
Font.Draw ("Welcome to The Chicken Wing ", 32, 345, fonts, 1)
Font.Draw ("Factory", 216, 277, fonts, 1)
Font.Draw ("\"Once you come, you'll never go back\"", 272, 58, font, 1)
Pic.ScreenLoad ("chicken.jpg", 0, 0, picCopy)
%------------------------------------------------------------------------------
import GUI

procedure menu
    locate (1, 1)
    put "Loading Menu..."
end menu

var Menue : int := GUI.CreateButton (553, 12, 0, "Menu", menu)

loop
    exit when GUI.ProcessEvent
end loop


Mod Edit: Remember to use syntax tags! Thanks :) [syntax="Turing"]Code Here[/syntax]

-----------------------------------
Sam_sam
Fri Dec 19, 2008 9:03 pm

Re: How to make button help!?!
-----------------------------------
Thanks!.. Now I know :)
BUT I STILL NEED HELP.. LOL!

-----------------------------------
andrew.
Fri Dec 19, 2008 9:07 pm

RE:How to make button help!?!
-----------------------------------
The reason is that your first code (that you commented out) is before your loop with the GUI. Since the loop never ends, it never gets to draw the GUI button. Try putting that loop code in a procedure and then call it from the procedure menu.

e.g.
procedure mainmenu
    loop
        % blah blah blah
    end loop
end mainmenu

procedure menu
    put "Loading Menu..."
end menu

% Variables and stuff

% Make your button (var menue blah blah blah)

loop
    exit when GUI.ProcessEvent
end loop

That should be your basic structure of the code.

P.S. Try to make your variables have better names. Like fonts could be named fontPapyrus or menue could be named menuButton.

-----------------------------------
Sam_sam
Fri Dec 19, 2008 9:15 pm

Re: How to make button help!?!
-----------------------------------
OHH!! Maybe I should be more clear.. the commented out one with the loop is just there to help me when I want to know the coordinates of one point... it is nothing.. my main problem is the uncommented ones 
Thanks for trying! :)

This is the new code:


%------------------------------------------------------------------------------
% var fonts : int
% var font : int
% setscreen ("graphics")
% colorback (yellow)
% cls
% fontPapyrus := Font.New ("Papyrus:30:italic")
% assert fonts > 0
% fontArial := Font.New ("Arial:12:italic")
% assert font > 0
% Font.Draw ("Welcome to The Chicken Wing ", 32, 345, fontPapyrus, 1)
% Font.Draw ("Factory", 216, 277, fonts, 1)
% Font.Draw ("\"Once you come, you'll never go back\"", 272, 58, fontArial, 1)
% Pic.ScreenLoad ("chicken.jpg", 0, 0, picCopy)
%------------------------------------------------------------------------------
import GUI

procedure mainmenu
    locate (1, 1)
    put "Loading Menu..."
end mainmenu

var Menue : int := GUI.CreateButton (553, 12, 0, "Menu", mainmenu)

loop
    exit when GUI.ProcessEvent
end loop

-----------------------------------
andrew.
Fri Dec 19, 2008 9:23 pm

RE:How to make button help!?!
-----------------------------------
Oh, imports have to be the first things that you do. Move your import statement to the very top and it will work.

-----------------------------------
Sam_sam
Fri Dec 19, 2008 9:29 pm

Re: How to make button help!?!
-----------------------------------
Now.. I have stumbled upon a new Problem..*sigh*
It only shows the button..:(

-----------------------------------
Tyr_God_Of_War
Fri Dec 19, 2008 9:47 pm

RE:How to make button help!?!
-----------------------------------
I think the best way to solve your problem is to abandon the built in GUI.  If you right your own code it will be easy for you to fix it, as you will understand it. Look into the tutorials and Mouse.Where.

-----------------------------------
Sam_sam
Fri Dec 19, 2008 9:52 pm

Re: How to make button help!?!
-----------------------------------
Thanks Guys!.. I'll check it out 2morrow.. need to sleep
Bye

-----------------------------------
Sam_sam
Sat Dec 20, 2008 6:03 pm

Re: How to make button help!?!
-----------------------------------
Do you mean the the type where you click on and area and it ACTS like a button..?

-----------------------------------
Insectoid
Sat Dec 20, 2008 6:12 pm

RE:How to make button help!?!
-----------------------------------
It doesn't act like a button, it is a button. That is essentially how every mouse-oriented button works. It's easier because you can tell it exactly what to do, when do disappear, what it looks like. It is far better than the built-in GUI.

-----------------------------------
Sam_sam
Sat Dec 20, 2008 10:04 pm

Re: How to make button help!?!
-----------------------------------
Can you give me an example of a type of code?
Greatly Appreciated :)

-----------------------------------
Clayton
Sat Dec 20, 2008 10:35 pm

RE:How to make button help!?!
-----------------------------------
Search Turing Submissions for Custom Buttons. I know myself and others have submitted some nifty modules for creating buttons that aren't Turing's built-in buttons.

-----------------------------------
Sam_sam
Sun Dec 21, 2008 1:25 pm

Re: How to make button help!?!
-----------------------------------
Ok.. it helped... but a little
I know that I am being picky, but I really would like to understand..
can someone maybe give me a quick run down of how to make a button, or suggest a place for newbies like me
to go?
Thanks

-----------------------------------
andrew.
Sun Dec 21, 2008 3:37 pm

RE:How to make button help!?!
-----------------------------------
Well, all you have to do is have Mouse.Where in your main loop so that your mouse position is checked each time. Then whenever the mouse x and y values are over the "button" you made and the mouse button is pressed, then it will do what you want.  Basically, you do that with an if statement and because of this, you can put what you want to do inside the if statement and you don't have to make another procedure).

EDIT: To make your button, you draw a rectangle or something. Maybe use a picture or something.

-----------------------------------
Sam_sam
Sun Dec 21, 2008 6:03 pm

RE:How to make button help!?!
-----------------------------------
Thanks SO MUCH! :D

-----------------------------------
Insectoid
Sun Dec 21, 2008 9:43 pm

RE:How to make button help!?!
-----------------------------------
[url=http://compsci.ca/v3/viewtopic.php?t=6]This and [url=http://compsci.ca/v3/viewtopic.php?t=13661]this.

-----------------------------------
Sam_sam
Wed Dec 31, 2008 4:02 pm

RE:How to make button help!?!
-----------------------------------
Thanks
