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.

Dark GDK / Dark gdk. need help whit a buttons

Author
Message
FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 7th Dec 2008 18:54
Hey, ive been building my game a lot, but then ive got stuck, whit my menu i need help on.

-1.
How do you create a mouse click button event.
pleas help.


-2.
How to create a mouseover button event(i woould like to make the button glow then, but i know how to do that)

-3.
i cant make my image streach. acrros the screen.

i try this code



need help.--thnx in advance

Game.Love
thanoulas
15
Years of Service
User Offline
Joined: 29th Nov 2008
Location:
Posted: 7th Dec 2008 19:52
I can help you with the mouse click events.
The function is dbMouseClick() which returns an int depending on which mouse button was clicked (1=left click, 2=right click, 4=middle button and 8=fourth button click if any, and their sums if they're clicked together for example 3=left and right), so you would need in your game loop for, say, left click:

CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 8th Dec 2008 10:36
2. You should check the mouse position. I have made a function that checks if the mouse is over a sprite:


3. The stretch value is in percent. You must count how many percent the image should stretch to fit the screen. And you can't stretch images for some reason, you must use sprites. Here is an example of a stretching function:
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 8th Dec 2008 11:09
Thanks CheatCat,

dbMouseX()
dbMouseY()

There is no mention in the "Dark GDK" -> "Documentation" -> "Information" , of the existence of there 2 functions.

I always wondered how people found the actual mouse position.
FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 8th Dec 2008 14:14
i got this errors from the maouseover function
the code:




Game.Love
FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 8th Dec 2008 14:24
I would like the image to adapt to any screen.

Game.Love
FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 8th Dec 2008 14:30
What do this numbers mean?
I mean the number at the end of the ==


Game.Love
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 8th Dec 2008 17:52
Quote: "i got this errors from the maouseover function"


Remove the second '{', the one on the line before "return true;"

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 8th Dec 2008 18:18
Dosent work (Remove the second '{', the one on the line before "return true;")

is used this code



got this errors

i trs removing others to they dont work eathere

Game.Love
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 8th Dec 2008 18:37
If the following doesn't do it then I don't know what the problem is.



Lilith, Night Butterfly
I'm not a programmer but I play one in the office
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 8th Dec 2008 22:58


There is nothing wrong with your particular function.
It compiles fine by itself.

The problem lies somewhere else in your code ..... maybe your function prototype is faulty, or you are calling it incorrectly within your code, or there is another coding error that is making the compiler think your function is faulty.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 8th Dec 2008 23:07
Looking at the error again it might be that the function is defined in the wrong place. The compiler complains that local functions are illegal. Local to what? Inside another function maybe?

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 9th Dec 2008 16:20
ok finaly go it to work(the button click) here is the code:


but for some reson i dont seem to get the exit to work:
this

an this:

dosent work.

now i am going to try to strech the image, across the screen.

Game.Love
FIGHTEX
15
Years of Service
User Offline
Joined: 30th Nov 2008
Location:
Posted: 9th Dec 2008 16:24
vops i meant and i dont get any errors, it just dosent work
this

and this


Game.Love
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 9th Dec 2008 17:11
Let us look at your "if" conditions.

Your first one:

if ( dbMouseX()> 0 && dbMouseX()< 0 + 200 && dbMouseY() > 0 && dbMouseY()< 0 + 70 )


I always use brackets to make sure there is never a chance of confusion, or possibility of errors. I would have written it as:

if ( (dbMouseX()> 0) && (dbMouseX()< (0 + 200)) && (dbMouseY() > 0) && (dbMouseY()< (0 + 70)) )

I suspect the way you have written your line, it actually equates out to:

if ( 70 )

Maybe some one else can confirm this as I could be wrong.

You may not be checking for the condition that you think you are checking for.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 9th Dec 2008 17:27
You're right, the tests need to be nested properly.

One other thing to keep in mind is that the dbMouseClick(int button) function will register a true as long as the button is held down. You have to manage it in order know know when the mouse button is newly clicked or released. Otherwise you can end up with a click status inside a loop as long as you hold down the button. Regardless of how quickly you may click it, it can still register as multiple clicks.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office

Login to post a reply

Server time is: 2024-09-30 11:19:11
Your offset time is: 2024-09-30 11:19:11