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.

Newcomers DBPro Corner / mouseclick command

Author
Message
mo2970
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location:
Posted: 17th Jul 2006 06:11
ok, i have a que about a simple command and i dont know how to use it. the mouseclick command is needed for what i have planned and i know a lot of people have no trouble with it, i do and i dont know how to use it. i figured it was a DBP forum que but it is so simple i thought i could use it here in the newcommers. so this is all i have right now.



i dont think i have the code right cuz it says i dont have the proper parameters or somethin like that. anyone out there who can help?

Deep, into that darkness peering, long i stood there, wondering, fearing, doubting. -Edgar Allen Poe
slicer 4 ever
18
Years of Service
User Offline
Joined: 11th Jul 2006
Location: currently: planet gamma3295
Posted: 17th Jul 2006 06:22
REM Project: project X III
REM Created: 7/16/2006 2:17:27 PM
sync on
sync rate 0

gosub _load_media
gosub _load_screen



_load_media:
load image "media/new game button.bmp",1
load image "media/secrets button.bmp",2
load image "media/exit button.bmp",3
return

_load_screen:
sprite 1,20,300,1
sprite 2,20,350,2
sprite 3,20,400,3
repeat
rem right here is the problem
if mouseclick ()=1 then goto _new_game
if mouseclick ()=2 then goto _secrets
if mouseclick ()=3 then end
until mouseclick

_new_game:
print "insert new game here"
wait key
end

_secrets:
print "insert secrets here"
wait key
end

look at the mouse click now

my smiles love me =-)=-)=-)(-=(-=(-=
mo2970
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location:
Posted: 17th Jul 2006 07:18
thank you for trying but it isnt working hmm i am lookin for a tut on it i have seen one before

Deep, into that darkness peering, long i stood there, wondering, fearing, doubting. -Edgar Allen Poe
slicer 4 ever
18
Years of Service
User Offline
Joined: 11th Jul 2006
Location: currently: planet gamma3295
Posted: 17th Jul 2006 07:31 Edited at: 17th Jul 2006 07:32
o oops sorry your using dbp i use dbc sorry(didn't see that)

my smiles love me =-)=-)=-)(-=(-=(-=
Slayer93
20
Years of Service
User Offline
Joined: 5th Aug 2004
Location: I wish I knew
Posted: 17th Jul 2006 08:06
dbp and dbc is the same with mouseclick.

Mouseclick returns a value so

until mouseclick is the problem because your not doing anything with it. So just put until mouseclick() > 0 or something along the lines of that.

Naruto is the ninja...not really
slicer 4 ever
18
Years of Service
User Offline
Joined: 11th Jul 2006
Location: currently: planet gamma3295
Posted: 17th Jul 2006 08:11 Edited at: 17th Jul 2006 08:13
o if that is the case then i was correct ecept for:

REM Project: project X III
REM Created: 7/16/2006 2:17:27 PM
sync on
sync rate 0

gosub _load_media
gosub _load_screen



_load_media:
load image "media/new game button.bmp",1
load image "media/secrets button.bmp",2
load image "media/exit button.bmp",3
return

_load_screen:
sprite 1,20,300,1
sprite 2,20,350,2
sprite 3,20,400,3
repeat
rem right here is the problem
if mouseclick()=1 then goto _new_game
if mouseclick()=2 then goto _secrets
if mouseclick()=3 then end
until mouseclick

_new_game:
print "insert new game here"
wait key
end

_secrets:
print "insert secrets here"
wait key
end

if you copied it exactly and added the space between mouseclick and () then that is the prob i just did a quick test to make sure now try it by placeing the () and mousclick together like so:

not work:
mouseclick ()=1
..................||
work..........||
mouseclick()=1

(dots because it removes spaces

my smiles love me =-)=-)=-)(-=(-=(-=
mo2970
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location:
Posted: 17th Jul 2006 10:01
i got it FINALLY workin! lol it looks like this. woo hoo!



yay for easy to learn, easy to debug DBPro!

Deep, into that darkness peering, long i stood there, wondering, fearing, doubting. -Edgar Allen Poe
mo2970
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location:
Posted: 17th Jul 2006 10:07
oh wait that almost does it but one problem, it is 1 as in left mouse button rather than 1 for sprite one, how do i fix that?

Deep, into that darkness peering, long i stood there, wondering, fearing, doubting. -Edgar Allen Poe
Cloggy
20
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 17th Jul 2006 10:57 Edited at: 21st Jul 2006 10:25
The mouseclick command returns the number of the button that has been clicked. What you need to do is determine which button the mouse is over when button 1 is clicked.

The easiest way to do this is to create a 1 pixel square sprite which you then test for collision with the image sprites you are using for your menu



You could use a select case statement on the sprite hit command



personally I would use gosubs rather than gotos as well.

Hope this helps.

Cheers,

Cloggy
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 19th Jul 2006 22:18 Edited at: 22nd Jul 2006 21:14
Quote: "The easiest way to do this is to create a 1 pixel square sprite which you then test for collision with the image sprites you are using for your menu"

Thanks for pointing that out, Cloggy! I ought to do that for my next menu!

mo2970
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location:
Posted: 21st Jul 2006 07:47
ok i have a new problem and i cant get this to work. the DB Pro assistant is no help with this command.

i have no clue how to set a sprite then make an "if" if the mouse clicks on it

Deep, into that darkness peering, long i stood there, wondering, fearing, doubting. -Edgar Allen Poe
Cloggy
20
Years of Service
User Offline
Joined: 31st Oct 2004
Location: Rayleigh, Essex
Posted: 21st Jul 2006 10:25
As show in the code from my previous post, you first check for a mouseclick, you then check for a collision between the 1 pixel square sprite which you have positioned at mousex() and mousey().

You do this by using the SpriteHit command.



Sprite Hit(4,0) check for a collision between sprite 4 (the mouse position sprite and 0 (all sprites). This command returns the number of the sprite that has been collided with, zero meaning no collision.

It's this command that is telling you that the cursor is over a sprite.

Take a further look at my code above and you will see how it does this.

Cheers,

Cloggy
ThomasFN
20
Years of Service
User Offline
Joined: 26th Aug 2004
Location:
Posted: 21st Jul 2006 21:59
get the position and size of spirte (Left Corner: X, Y - Right Croner: X, Y) say your sporte was here:
00000
00110
00110
00110
00000

LX = 3
LY = 2
RX = 4
RY = 3

Then say:



basicaly u check if the mouse was clicked; then if the mouse was within the sprite bounds

mo2970
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location:
Posted: 23rd Jul 2006 04:38
Quote: "As show in the code from my previous post, you first check for a mouseclick, you then check for a collision between the 1 pixel square sprite which you have positioned at mousex() and mousey()."

oh! i get it now that is a huge help then thank you cloggy ( i miss read it earlier and i thought u said to make a 1 pixel button for u to click on with the mouse. i see now. thank you a lot!

Deep, into that darkness peering, long i stood there, wondering, fearing, doubting. -Edgar Allen Poe
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 23rd Jul 2006 13:18
Quote: " i miss read it earlier and i thought u said to make a 1 pixel button for u to click on with the mouse"


LOL You'd spend most of your time trying to find the button

mo2970
18
Years of Service
User Offline
Joined: 10th Jun 2006
Location:
Posted: 23rd Jul 2006 20:18
exactly and i had no clue what he was talkin about but now i know, it is a lot of help. lol

Deep, into that darkness peering, long i stood there, wondering, fearing, doubting. -Edgar Allen Poe

Login to post a reply

Server time is: 2024-11-26 16:21:28
Your offset time is: 2024-11-26 16:21:28