|
3 registered members (AndrewAMD, Grant, Neb),
908
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Help with panel fading code ...
#255061
03/07/09 11:40
03/07/09 11:40
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
Can someone help me with this 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
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
Senior Member
|
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.
event_type == EVENT_RELEASE
Greetings Ralph.
|
|
|
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
Senior Member
|
Senior Member
Joined: Feb 2006
Posts: 385
Oldenburg,Germany
|
Argh, I ignored this in the manual.. sorry.  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.
|
|
|
|