Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   This Is Ridiculous (https://forums.graalonline.com/forums/showthread.php?t=76582)

Kyranki 08-31-2007 03:35 AM

This Is Ridiculous
 
PHP Code:

//#CLIENTSIDE
enum {
  
MODE_NONE,
  
MODE_FADEINTEXT,
  
MODE_FADEOUTTEXT
}
function 
onCreated() {
  
hideimg(200);
  
this.mode = MODE_NONE;
  
fadeInText(1, "Welcome.", 2, "Comic Sans MS", "c");
}
public function 
fadeInText(time, stext, szoom, sfont, sstyle) {
  
with (findimg(200)) {
    
x = ((GraalControl.width / 2) - (this.width / 2));
    
y = ((GraalControl.height / 2) - (this.height / 2));
    
text = stext;
    
zoom = szoom;
    
font = sfont;
    
layer = 4;
    
style = sstyle;
    
visible = true;
    
alpha = 0;
  }
  
this.mode = MODE_FADEINTEXT;
  
this.fadeint = 0.05 / time;
  
  
setTimer(0.05);
}
function 
onTimeout() {
  switch (
this.mode) {
    case 
MODE_FADEINTEXT:
      echo(
"Fading in text.");
      
with (findimg(200)) {
        
alpha += thiso.fadeint;
        if (
alpha => 1) {
          
thiso.mode = MODE_NONE;
          
setTimer(0);
        }
      }
    break;
  }
  
setTimer(0.5);
} 

That should work perfectly. O_O And it refuses to work, what is happening is the image is not visible then it just becomes visible. With no fading. >:O

Inverness 08-31-2007 04:22 AM

Just copy my util_guifade class from Val Dev and join it to a GUI thingy.

DustyPorViva 08-31-2007 04:41 AM

I'm not quite getting this, and it seems a lot longer than it should be. I'd use a while instead of a timeout myself, but anyways, I think it's with the 0.05/time. Graal has a hard time handling smaller floating points sometimes, at least in my experience. If you're using a higher time, it might not be able to calculate the value, thus not increase the alpha.

Kyranki 08-31-2007 04:47 AM

Quote:

Originally Posted by Inverness (Post 1344847)
Just copy my util_guifade class from Val Dev and join it to a GUI thingy.

I suppose I could make a gui text control and do that. Thanks Inver.

Quote:

Originally Posted by DustyPorViva (Post 1344854)
I'm not quite getting this, and it seems a lot longer than it should be. I'd use a while instead of a timeout myself, but anyways, I think it's with the 0.05/time. Graal has a hard time handling smaller floating points sometimes, at least in my experience. If you're using a higher time, it might not be able to calculate the value, thus not increase the alpha.

Hmm, thanks for the info Dusty. I'll make sure to test that out in the future. :O

Chompy 08-31-2007 12:18 PM

Uhm?

You're increasing the alpha by (0.05/time) which in your case is 0.005 every 0.5 secs.. So.. my guess it, IT WILL TAKE LONG TIME

oh, and: use this.alpha instead of simple just alpha :o
Then you know what object you're working with :p

Crow 08-31-2007 02:29 PM

Yea, might be a problem with the object, thats why I always use:

PHP Code:

findimg(200).alpha 

I had some similar problem before. Actually, almost the same. I wanted to fade text, tried to do it like you did, but it didnt work ;P

Inverness 08-31-2007 10:16 PM

This is the script I use for fading on Val Dev, it is to be joined to a Gui Control object.

PHP Code:

//#CLIENTSIDE
enum {
  
M_NONE,
  
M_FADEIN,
  
M_FADEOUT
}
public function 
fadeIn(time, toalpha) {
  if (
this.fademode != M_NONE)
    return;
  
this.fademode = M_FADEIN;
  
this.fadeint = 0.05 / time;
  
this.fadeto = toalpha;
  
this.visible = true;
  
this.fading = true;
  
setTimer(0.05);
}
public function 
fadeOut(time, toalpha) {
  if (
this.fademode != M_NONE)
    return;
  
this.fademode = M_FADEOUT;
  
this.fadeint = 0.05 / time;
  
this.fadeto = toalpha;
  
this.visible = true;
  
this.fading = true;
  
setTimer(0.05);
}
function 
onTimeout() {
  switch (
this.fademode) {
    case 
M_FADEIN:
      
this.alpha += this.fadeint;
      if (
this.alpha >= this.fadeto) {
        
this.fademode = M_NONE;
        
this.fading = false;
        
setTimer(0);
      }
      else {
        
setTimer(0.05);
      }
      break;
    case 
M_FADEOUT:
      
this.alpha -= this.fadeint;
      if (
this.alpha <= this.fadeto) {
        
this.fademode = M_NONE;
        if (
this.fadeto == 0) {
          
this.visible = false;
        }
        
this.fading = false;
        
setTimer(0);
      }
      else {
        
setTimer(0.05);
      }
      break;
  }
} 



All times are GMT +2. The time now is 12:06 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.