Uses alpha in order to fade it in and out depending on if you're hovering your mouse over the GuiCtrl or not.
Complete script, with a GuiWindowCtrl included as example on usage.
PHP Code:
//#CLIENTSIDE
function onCreated()
{
new GuiWindowCtrl("ExampleGui") {
alpha = this.baseAlpha = .3;
thiso.catchevent(this, "onMouseEnter", "onMouseEnter");
thiso.catchevent(this, "onMouseLeave", "onMouseLeave");
}
}
function onMouseEnter(obj) scheduleevent(.05, "FadeGUI", "setValue", obj, 1);
function onMouseLeave(obj) scheduleevent(.05, "FadeGUI", "setValue", obj, obj.baseAlpha);
function onFadeGUI(mode, obj, value)
{
// mode: 'setValue' or 'changeAlpha'
// obj: GuiCtrl or name of GuiCtrl
// value: Alpha to reach
temp.modifier = .1; // How much should the alpha change every 0.05 seconds?
// Let's lets make sure that 'obj' really is a GuiCtrl, shall we?
if (obj.name == "obj") {
// If the GuiCtrl exists, we got it!
with ((@obj)) obj = this;
// Can't change alpha on a TGraalVar!
if (obj.objecttype() == "TGraalVar") return;
}
// Tadaa!
if (mode == "setValue") {
cancelEvents("changeAlpha");
obj.targetAlpha = value;
scheduleevent(.05, "FadeGUI", "changeAlpha", obj);
} else if (mode == "changeAlpha") {
if (obj.alpha != obj.targetAlpha) {
if (obj.alpha > obj.targetAlpha) obj.alpha -= temp.modifier;
else if (obj.alpha < obj.targetAlpha) obj.alpha += temp.modifier;
scheduleevent(.05, "FadeGUI", "changeAlpha", obj);
} else cancelEvents("changeAlpha");
}
}
As always, please, use the forums reputation system to show if you like the script or not. Don't hesitate to leave your name saying who you are, I won't "strike back" if you give me negative rep!
