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.

2D All the way! / Clickable Buttons?

Author
Message
Jimi
20
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 19th Jan 2004 21:25
I want to have a GUI with various buttons on, but (stupidly) I don't know how to have clickable buttons. How do i do it?

Penfold
20
Years of Service
User Offline
Joined: 3rd Dec 2003
Location: RED postbox houses of parliment
Posted: 19th Jan 2004 23:13
You have to make your program check for mouse clicks and then if they click a certain area of the screen or on a certain sprite then it needs to print a clicked version sprite/.bmp over the unclicked version to make it look as though it has been pressed.

'Ooh 'eck chief'...'crumbs'
Jimi
20
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 19th Jan 2004 23:29
how do i perform a check for a certain area or over the sprite?

Slayer
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: CA
Posted: 19th Jan 2004 23:39
mousex() mousey()

I dont know how to spell
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 20th Jan 2004 04:28
Here's an easy function I use quite often.




"eureka" - Archimedes
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 20th Jan 2004 20:23
There's a program called DB_Builder that makes these zones for you. Now all you have to do is find this ancient piece of software.

Penfold
20
Years of Service
User Offline
Joined: 3rd Dec 2003
Location: RED postbox houses of parliment
Posted: 20th Jan 2004 20:46
CMC101 wow you printed some code I'm gonna use...

'Ooh 'eck chief'...'crumbs'
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 31st Jan 2004 13:12
You should changed that to:



Just 1 less variable to have.

"eureka" - Archimedes
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 31st Jan 2004 17:45
if you used sprites for the buttons and change to mouse pointer to a sprite, all you need to do is check sprite collision
you need to hide mouse
and put a sprite where mousex and mousey
then just check collision between the new mouse pointer sprite and all the button sprites.

RGT may be gone but the best DBP forum is still alive and kicking, check it out.
http://www.dannywartnaby.co.uk/rgt/
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 1st Feb 2004 05:13
You don't even need to hide the mouse and use a replacement image. just use a 1x1 transparent sprite positioned at the mouse position instead.

CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 1st Feb 2004 07:53
Quote: " transparent sprite "
- that's a good one, never thought of that before.

RGT may be gone but the best DBP forum is still alive and kicking, check it out.
http://www.dannywartnaby.co.uk/rgt/
Cros Jovil
20
Years of Service
User Offline
Joined: 27th Jan 2004
Location:
Posted: 9th Feb 2004 20:21


thats seems like to many ifs save some space

CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 10th Feb 2004 08:22
yeah, but nested (if thens) are faster then 1 big (if then) with many expressions
but why worry with checking 4 point every cycle, I used to do it just that way, but now I find this easyer to debug and track and is more flexible.

make a invisible image name it mouse_pointer, or use any image and hide that sprite, (DBP still collides sprite when hidden)
and have button images, button1,button2, ect
then


RGT may be gone but the best DBP forum is still alive and kicking, check it out.
http://www.dannywartnaby.co.uk/rgt/
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 10th Feb 2004 16:46 Edited at: 10th Feb 2004 16:48
There is no need to check buttons every cycle anyway, no matter what method you use. You only need to check for a button when the mouse is clicked. So you can take this line out for a start.....

and mouseclick()=1

Pincho.

AnDrEy
20
Years of Service
User Offline
Joined: 11th Jan 2004
Location: In Da Club
Posted: 17th Feb 2004 17:44 Edited at: 17th Feb 2004 17:51
VERY SIMPLE LOOK AT THIS using the sprite idea from the_winch
(it checks menu which the mouse is over and if it clicked on it with multiple menus) you can add the gosub_ yourselves.
Ralen
20
Years of Service
User Offline
Joined: 22nd Jul 2003
Location:
Posted: 22nd Feb 2004 08:28
instead of hiding the mouse hide the sprite. If you hide the mouse then the sprite will always lag behind the mouse. Hide the sprite and you don't notice the curser sprite lagging.

Ralen
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 22nd Feb 2004 14:26
I haven't noticed any lagging behind.

Login to post a reply

Server time is: 2024-05-17 07:45:49
Your offset time is: 2024-05-17 07:45:49