
-----------------------------------
Jorue
Wed Jan 06, 2010 11:20 am

Buttons -- Help?
-----------------------------------
What is it you are trying to achieve?
Finish my damn game before Friday, when it's due! ><


What is the problem you are having?
I am not sure how to detect when a button is clicked.

Describe what you have tried to solve this problem
Nothing, I have absolutely no idea how to do it.

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)








Please specify what version of Turing you are using
4.1.1

-----------------------------------
Jorue
Wed Jan 06, 2010 12:17 pm

RE:Buttons -- Help?
-----------------------------------
...Bump

-----------------------------------
mirhagk
Wed Jan 06, 2010 12:27 pm

RE:Buttons -- Help?
-----------------------------------
please be a little more specific, are you using GUI, or trying to draw your own buttons. Or are you simply to lazy to even attempt to create it and want us to explain it?? I can show you link you some topics if you tell us what you actually want. Include the question that your working on so that we know what your trying to attempt.

-----------------------------------
Jorue
Wed Jan 06, 2010 12:29 pm

RE:Buttons -- Help?
-----------------------------------
I am using GUI buttons

-----------------------------------
Jorue
Wed Jan 06, 2010 12:55 pm

RE:Buttons -- Help?
-----------------------------------
Okay, let me clarify some more. I have a menu with three options, "Play" "Instructions" "Exit" Now, the question is, how can I have it tell which one is clicked?

-----------------------------------
Insectoid
Wed Jan 06, 2010 1:47 pm

RE:Buttons -- Help?
-----------------------------------
Give us your code, we may find it useful. Also,  (Turing's)GUI buttons suck, make your own and use mouse commands.

-----------------------------------
Jorue
Wed Jan 06, 2010 1:56 pm

RE:Buttons -- Help?
-----------------------------------

xbutton := GUI.CreatePictureButton (325, 250, play1, playstart)


Then, for that Process, I have:


procedure playstart
for count : 1 .. 10
    Sprite.Show (enemies1 (count, 1))
    Sprite.Show (enemies2 (count, 1))
    Sprite.Show (enemies3 (count, 1))
    Sprite.Show (enemies4 (count, 1))
    Sprite.Show (enemies5 (count, 1))
    Sprite.Show (enemies6 (count, 1))
    Sprite.SetPosition (enemies1 (count, 1), enemies1 (count, 2), enemies1 (count, 3), true)
    Sprite.SetPosition (enemies2 (count, 1), enemies2 (count, 2), enemies2 (count, 3), true)
    Sprite.SetPosition (enemies3 (count, 1), enemies3 (count, 2), enemies3 (count, 3), true)
    Sprite.SetPosition (enemies4 (count, 1), enemies4 (count, 2), enemies4 (count, 3), true)
    Sprite.SetPosition (enemies5 (count, 1), enemies5 (count, 2), enemies5 (count, 3), true)
    Sprite.SetPosition (enemies6 (count, 1), enemies6 (count, 2), enemies6 (count, 3), true)
end for
Sprite.Show (player)
Sprite.SetPosition (player, x, y - 155, true)
fork ship
fork bulletshoot
fork enemymove
fork enemyshoot1
end playstart


That code is simply to have the enemies appear, the player to appear, and then cause the game to run. However, when I start the game, all I get is the title screen, [with no buttons, mind you] and the BGM playing.

-----------------------------------
DemonWasp
Wed Jan 06, 2010 2:51 pm

RE:Buttons -- Help?
-----------------------------------
You can use Mouse.Where() to detect the current status of the mouse. You can use it in a loop to keep track of mouse status. You can check for when certain events happen (left-mousebutton-down, left-mousebutton-up, right-...etc). You can then decide what to do based on that.

For an example of that, you can look at my [url=http://compsci.ca/v3/viewtopic.php?t=21727]Minesweeper Tutorial.

-----------------------------------
Jorue
Wed Jan 06, 2010 2:58 pm

Re: Buttons -- Help?
-----------------------------------
Right, but the buttons don't show up period, even though they should. Here, let me attach the game.

-----------------------------------
DemonWasp
Wed Jan 06, 2010 7:19 pm

RE:Buttons -- Help?
-----------------------------------
Oh! You're trying to use the GUI module, so my previous advice doesn't apply. You also need a loop polling for GUI interaction (look at any of the examples in the GUI help and copy the loop construct they have towards the bottom, with something like GUI.ProcessEvents() ).

-----------------------------------
imbored
Wed Jan 06, 2010 10:01 pm

RE:Buttons -- Help?
-----------------------------------
use Mouse.ButtonWait and cordinates... i hate gui... its so confusing just telling you. just use Mouse.Where and only activate when it is inside the cordinates of mouse where AND if Mouse.ButtonWait is down.

-----------------------------------
registration
Thu Jan 07, 2010 7:21 pm

Re: RE:Buttons -- Help?
-----------------------------------

xbutton := GUI.CreatePictureButton (325, 250, play1, playstart)


Then, for that Process, I have:


procedure playstart
for count : 1 .. 10
    Sprite.Show (enemies1 (count, 1))
    Sprite.Show (enemies2 (count, 1))
    Sprite.Show (enemies3 (count, 1))
    Sprite.Show (enemies4 (count, 1))
    Sprite.Show (enemies5 (count, 1))
    Sprite.Show (enemies6 (count, 1))
    Sprite.SetPosition (enemies1 (count, 1), enemies1 (count, 2), enemies1 (count, 3), true)
    Sprite.SetPosition (enemies2 (count, 1), enemies2 (count, 2), enemies2 (count, 3), true)
    Sprite.SetPosition (enemies3 (count, 1), enemies3 (count, 2), enemies3 (count, 3), true)
    Sprite.SetPosition (enemies4 (count, 1), enemies4 (count, 2), enemies4 (count, 3), true)
    Sprite.SetPosition (enemies5 (count, 1), enemies5 (count, 2), enemies5 (count, 3), true)
    Sprite.SetPosition (enemies6 (count, 1), enemies6 (count, 2), enemies6 (count, 3), true)
end for
Sprite.Show (player)
Sprite.SetPosition (player, x, y - 155, true)
fork ship
fork bulletshoot
fork enemymove
fork enemyshoot1
end playstart


That code is simply to have the enemies appear, the player to appear, and then cause the game to run. However, when I start the game, all I get is the title screen, 

Make sure your
loop
....exit when GUI.ProcessEvent
end loop
is after you make the GUI.CreatePictureButton or w/e. The procedure you call when button is pressed should have a GUI.Quit at the end, and make sure you do View.Update if you're using offscreenonly. (also make sure you draw the GUI after the background picture).
