Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-31-2007, 03:35 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
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(timestextszoomsfontsstyle) {
  
with (findimg(200)) {
    
= ((GraalControl.width 2) - (this.width 2));
    
= ((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
__________________
Stan.
Reply With Quote
  #2  
Old 08-31-2007, 04:22 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Just copy my util_guifade class from Val Dev and join it to a GUI thingy.
__________________
Reply With Quote
  #3  
Old 08-31-2007, 04:41 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
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.
Reply With Quote
  #4  
Old 08-31-2007, 04:47 AM
Kyranki Kyranki is offline
Freelance Coder
Join Date: Aug 2007
Location: At the end of the rainbow, in the pot of gold.
Posts: 202
Kyranki is on a distinguished road
Send a message via AIM to Kyranki Send a message via MSN to Kyranki
Quote:
Originally Posted by Inverness View Post
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 View Post
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
__________________
Stan.
Reply With Quote
  #5  
Old 08-31-2007, 12:18 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
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
__________________
Reply With Quote
  #6  
Old 08-31-2007, 02:29 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
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
Reply With Quote
  #7  
Old 08-31-2007, 10:16 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
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(timetoalpha) {
  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(timetoalpha) {
  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;
  }

__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:40 AM.


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