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 / [DBP] user interface help

Author
Message
Merk
18
Years of Service
User Offline
Joined: 5th Feb 2006
Location:
Posted: 12th Jul 2006 11:28
Hey,
I've hit a snag on what should be a really simple problem to solve. I want to have a sprite to become visible when the user clicks its button (also a sprite). A second click should close/hide the panel. Now its pretty simple (even for me) to get the panel to pop up on a mouse click, but the logic behind my function is no good making it disappear on a second click:



Where the Panel() array holds information on buttons and panels of the user interface, and the .active variable is a boolean which is set to 1 (another function in the code later checks the .active value of each item and set visibility based on that).

The remmed out lines are definitely where the problem is coming from, since it'll detect the same mouse click that would set the active variable as 1, instantly changing back to 0.

So does anyone know how fix this?
Thanks in advance ,
Merk.

Attachments

Login to view attachments
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 12th Jul 2006 12:19
Yeah, you have a prob - read your logic:

If I have clicked the mouse,
If panel is inactive set it to active

If I have clicked the mouse,
If panel is active (which it now is!) make it inactive.

Try setting up your logic using an ELSE clause:
If I have clicked the mouse,
If panel is inactive set it to active
ELSE
set it to inactive

It seems from the above code that you will be ok to run with this, but if not let me know and I'll code it for you!
Hope this helps!

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Merk
18
Years of Service
User Offline
Joined: 5th Feb 2006
Location:
Posted: 12th Jul 2006 12:58
Hey death, yes an else statement like that works. Just now it flickers between being visible and invisible when you keep your finger on the mouse button. I've had this problem before, and normally something like this works:


But if you try that with a second if statement after the hold value change to 2 it won't do you any good (like this):


All you get is the hold value switching between 3 and 4 (you can get rid of hold = 3, hold = 4 and you get the same result) as long as mouseclick() = 1. There must be a better way of having one action occur per mouse click, even if you hold the mouse button down.

Help and suggestions most appreciated ,
Merk.
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 12th Jul 2006 13:04 Edited at: 12th Jul 2006 13:04
Try this: You will need to make MouseHeld global to get it to work, but I think it will do what you want!


"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Merk
18
Years of Service
User Offline
Joined: 5th Feb 2006
Location:
Posted: 12th Jul 2006 13:53
neat! That works a treat, thank you dream and death

Merk.

Login to post a reply

Server time is: 2024-11-26 15:40:05
Your offset time is: 2024-11-26 15:40:05