L
L0v3
Guest
Working on tweening highlight effect for mouseover on object, in my scenario to be used for changing the drawing alpha of an object on mouseover, will make more generic later.
The below code works perfectly fine for this, however, if you leave/enter the mouse before the tween have finished, you will start the fadeout effect as if it were finished.
Example; on mouseover it will fade the object in over 2 seconds, at 1 second you leave the mouse, and when doing so, the fade out effect will cause the alpha to jump from half faded in to as if it were fully opaque, and then start fading out. This causing some annoying blinking effects.
Heres the code:
What I am looking for is a way for this not to occur. My ideas have been taking a snapshot of some variables when mouse leaves, but not quite sure how to implement this. Have experimented to no avail, and raised alot more questions instead. Been tunnel visioned most of day on this so decided to make a topic.
The below code works perfectly fine for this, however, if you leave/enter the mouse before the tween have finished, you will start the fadeout effect as if it were finished.
Example; on mouseover it will fade the object in over 2 seconds, at 1 second you leave the mouse, and when doing so, the fade out effect will cause the alpha to jump from half faded in to as if it were fully opaque, and then start fading out. This causing some annoying blinking effects.
Heres the code:
Code:
//Alpha Highlighting.
if position_meeting(mouse_x, mouse_y, self) and !complete_fadein //Mouseover
{
//Makes fadeout incomplete.
complete_fadeout = false;
//Mouseover Fade In
image_alpha = tween_linear(step, duration, lower, upper);
step++;
//Check if complete.
if (step > duration)
{
complete_fadein = true;
step = 0;
}
}
else if !position_meeting(mouse_x, mouse_y, self) and !complete_fadeout //No Mouseover
{
//Makes fadein incomplete.
complete_fadein = false;
//No Mouse Fade Out
image_alpha = tween_linear(step, duration, upper, lower);
step++;
//Check if complete.
if (step > duration)
{
complete_fadeout = true;
step = 0;
}
}
What I am looking for is a way for this not to occur. My ideas have been taking a snapshot of some variables when mouse leaves, but not quite sure how to implement this. Have experimented to no avail, and raised alot more questions instead. Been tunnel visioned most of day on this so decided to make a topic.