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 / Icons clicking

Author
Message
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 20th Jun 2004 19:01
Ok how do I made a icon on the screen that if you click it something happens?

A 1 man team
EVIL SIG!
Guhill The friendly one
20
Years of Service
User Offline
Joined: 12th Jun 2004
Location: The fourth demension
Posted: 20th Jun 2004 19:16 Edited at: 20th Jun 2004 19:20
Get the mouse coordinates using mousex() and mousey() to make a box around the area that you click and put it in an if statement. Also in the if statement put mouseclick()=1. So it should look like this if mouseclick()=1 and
mousex()>the cordinates of the right side of the box and mousex()<the cordinates of the left side of the box and mousey()>the cordinates of the top of the box and mousey()<the cordinates of the bottom of the box
that should all go in one line. Under that line (use as many lines as you will need for this part) put what happens when you click in that area. And when you finish telling the computer what happens when you do that put endif under it all.

(If you want to know the mouse coordinates while running your program just type print mousex() : print mousey().)

I know now, without a doubt, that Kingdom Hearts... IS LIGHT (Sora)
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 20th Jun 2004 21:48
or just hide the mouse and replace the pointer with one of your own, then make a sprite for the icon, and just use sprite hit to check for collision eg:

if sprite hit(1,2)=1 and mouseclick()=1 then do_function

checks for a pointer (sprite 1) hitting an icon (sprite 2) at the same time that a button is clicked, if both conditions are true then you can call a function to perform whatever operation should be performed by clicking the mouse, if you use a windows like arrow and dont want to have the icon selected by the tail (ie, when the tip of the arrow is off the icon) then make the arrow in two parts, a dot for the tip and another sprite for the body, or you can draw the icon in two parts and just use the lower right hand one for selection.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, Nvidia FX5900 gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster.

Login to post a reply

Server time is: 2024-09-22 14:28:06
Your offset time is: 2024-09-22 14:28:06