Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
3 registered members (AndrewAMD, Grant, Neb), 908 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Help with panel fading code ... #255061
03/07/09 11:40
03/07/09 11:40
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Can someone help me with this code:

Code:
int overButtonActive = 0;

function overButton(var buttonId, PANEL* panel) {
	int alphaFactor = 1;	
	overButtonActive = 1;
	var savedAlpha = panel.alpha;
	var newAlpha = 0;
	while (overButtonActive == 1) {		
		newAlpha = panel.alpha + (5*alphaFactor)*time_step;				
		if (newAlpha >= 100) {
			newAlpha = 100;
			alphaFactor = -1;
		}
		if (newAlpha <= 50 && alphaFactor == -1) {
			alphaFactor = 1;
			newAlpha = 50;
		}		
		panel.alpha = newAlpha;
		wait(1);
	}	
	panel.alpha = 100;
}

function buttonEvent() {
	if(event_type == EVENT_RELEASE) {
		overButtonActive = 0;
	}
}

PANEL* start_game_panel = {
	button(0,0,start_game_bmap,start_game_bmap,start_game_bmap,start_game,buttonEvent,overButton);
	layer = 5;
	pos_x = 362;
	pos_y = 675;
	alpha = 100;
	flags |= TRANSLUCENT | OVERLAY;
}


I use this code for a hover effect while the mouse arrow is over the button.
So far it works fine, but if I have a second button below using the same code and then move the mouse fast from above over the first button to the second, both buttons play the effect although the mouse is no more over the first button.

It seems like
Code:
if(event_type == EVENT_RELEASE) {
		overButtonActive = 0;
	}

isn't executed when moving very fast over the button (or something like this).

Any ideas?

Regards,
Pegamode.

Re: Help with panel fading code ... [Re: pegamode] #255063
03/07/09 11:55
03/07/09 11:55
Joined: Feb 2006
Posts: 385
Oldenburg,Germany
Ralph Offline
Senior Member
Ralph  Offline
Senior Member

Joined: Feb 2006
Posts: 385
Oldenburg,Germany
#1 You have to made a Panel for every button you want to use with this effect.Because the effect fade the hole panel not only the button.
#2 This is a ENTITY parameter not a PANEL parameter!
So it shouldn't work.
Code:
event_type == EVENT_RELEASE


Greetings Ralph.

Re: Help with panel fading code ... [Re: Ralph] #255064
03/07/09 12:01
03/07/09 12:01
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hi Ralph,

thanks for your answer, but of course I use a panel for each button, and
panels can use event_type.

(PS: it works fine when not moving the mouse very fast over the button)

From the manual:

Button functions can compare the event_type variable to examine by which mouse event they were triggered. At the beginning of a function, event_type can have the following values:

EVENT_TOUCH - the mouse was moved over the button.
EVENT_RELEASE - the mouse was moved away from the button.
EVENT_CLICK - left mouse button was clicked over the button or switches a toggle button on.
EVENT_CLICKUP - left mouse button was clicked over a toggle button and switches it off.
EVENT_BUTTONUP - left mouse button was released over the button.

EVENT_RELEASE and EVENT_BUTTONUP can be used to distinguish whether functionOff was triggered by leaving the button area or releasing the mouse button. EVENT_CLICK and EVENT_CLICKUP can be used to distinguish whether the mouse click switches the toggle button on or off.


Re: Help with panel fading code ... [Re: pegamode] #255065
03/07/09 12:15
03/07/09 12:15
Joined: Feb 2006
Posts: 385
Oldenburg,Germany
Ralph Offline
Senior Member
Ralph  Offline
Senior Member

Joined: Feb 2006
Posts: 385
Oldenburg,Germany
Argh, I ignored this in the manual.. sorry. whistle
Your problem could be that you are using a global var for checking the fade-state.
So if the first button fade is allready running and you activate the secound one the first one will be reset (like you call it again). I think you have to rewrite your functions,but I have no idea how to do this dynamicly.
EDIT:
Dublicate the global var and the two functions to test it.
(I cant do it because your code doesnt work at my lite-c... I doesnt know why)

Greetings Ralph.


Last edited by Ralph; 03/07/09 12:17.
Re: Help with panel fading code ... [Re: Ralph] #255066
03/07/09 12:20
03/07/09 12:20
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
The next GS version adds skill_x, skill_y to panels which could be very helpful for storing such a value, but I also used proc_state to wait until there's only 1 running instance of the fading-function before setting the global var to value 1 ... still the same problem.

Re: Help with panel fading code ... [Re: pegamode] #255068
03/07/09 12:39
03/07/09 12:39
Joined: Feb 2006
Posts: 385
Oldenburg,Germany
Ralph Offline
Senior Member
Ralph  Offline
Senior Member

Joined: Feb 2006
Posts: 385
Oldenburg,Germany
I duplicate the functions + var and I get the same effect like you. I have no idea how to fix that. frown

Re: Help with panel fading code ... [Re: Ralph] #255071
03/07/09 12:51
03/07/09 12:51
Joined: Feb 2006
Posts: 1,011
Germany
pegamode Offline OP
Serious User
pegamode  Offline OP
Serious User

Joined: Feb 2006
Posts: 1,011
Germany
Hmmm ...

maybe it's a bug in GS?

Re: Help with panel fading code ... [Re: Ralph] #255072
03/07/09 12:52
03/07/09 12:52
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
Heya, can you send me a zipped version of what you have and I'll take a loot at it jks_here@hotmail.com


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1