Hello!
Sometimes I have a strange trouble with alpha.
w=Game.LoadWindow("scenes\test\w4.window");
w.FadeTo(0,1,0,0,0);
//e=w.GetControl("1");e=e.GetEntity();e.Rotatable=TRUE;e.Rotate=10;
w.Visible=TRUE;
w.FadeTo(1000,255,255,255,255);
Sleep(10000);
w.FadeTo(1000,1,0,0,0);
w.Visible=FALSE;
Game.UnloadObject(w);
.FadeTo() method is based on window's .AlphaColor property. So it works fine! But when I enable marked line (especially,
e.Rotatable=TRUE; operator), the entity always becomes visible, and the changing of .AlphaColor doesn't take effect. If I write
e.Rotatable=FALSE; operator, it works fine again. I'm embarassed
What the matter? Is trouble in the entity container or something else?
Although, .Rotatable is worked. And .AlphaColor not
Here is the piece of advanced script, attached to window
#include "scripts\base.inc"
var a0=255;
var r0=255;
var g0=255;
var b0=255;
method FadeTo(duration,a,r,g,b){
if(a==NULL)a=0;
if(r==NULL)r=0;
if(g==NULL)g=0;
if(b==NULL)b=0;
var tmp=Scene.GetNode("temp_entity");
var t0=Game.CurrentTime;
tmp.AlphaColor=this.AlphaColor;
if(tmp.AlphaColor==NULL||tmp.AlphaColor==0){
a0=255;
r0=255;
g0=255;
b0=255;
}
//Game.LOG("=WINDOW "+this.Name+" FADES=");
//Game.LOG("FROM: "+a0+" "+r0+" "+g0+" "+b0);
//Game.LOG(" TO: "+a+" "+r+" "+g+" "+b);
while(TRUE){
var dt;
if(duration>0)dt=(Game.CurrentTime-t0)/duration;else dt=1;
if(dt<0)dt=0;
if(dt>1)dt=1;
tmp.AlphaColor=0;
tmp.AlphaColor=tmp.AlphaColor*256+a0+(a-a0)*dt;
tmp.AlphaColor=tmp.AlphaColor*256+r0+(r-r0)*dt;
tmp.AlphaColor=tmp.AlphaColor*256+g0+(g-g0)*dt;
tmp.AlphaColor=tmp.AlphaColor*256+b0+(b-b0)*dt;
this.AlphaColor=tmp.AlphaColor;
if(dt==1){
if(a==255&&r==255&&g==255&&b==255)this.AlphaColor=NULL;
a0=a;
r0=r;
g0=g;
b0=b;
break;
}
Sleep(50);
}
}