Blackout text or something ? [SOLVED ]

Started by T-Pr, Tue 25/01/2011 16:19:36

Previous topic - Next topic

T-Pr

Hi everyone , i really suck at making credits , texts or such thing :P . I want this , for example , in some movies , there is a black screen and there is a text which says T-Pr Production . But this text doesn't appear quickly , it appears slowly like it's transparency is increasing , and then it disappears slowly again like it's transparency is decreasing. So how can i do that in my game , i want to do that at the beginning like credits in for example left top corner of the room.

Calin Leafshade

Put your text on a gui and use the code below to fade the gui in and out.

untested but

Code: ags

function Fade(this GUI*, int speed,  bool fadeIn){
int temp;

if (fadeIn) {

  this.Transparency = 100;
  this.Visible = true;
  while (this.Transparency > 0) {
    temp = this.Transparency - speed;
    if (temp < 0) temp = 0;
    this.transparency = temp;
    Wait(1);
  }
}
else {

  this.Transparency = 0;

  while (this.Transparency < 100) {
    temp = this.Transparency + speed;
    if (temp > 100) temp = 100;
    this.transparency = temp;
    Wait(1);
  }
  this.Visible = false;
 }

}



Usage is like this:

Code: ags


myGui.Fade(2, true); // fades in with a speed of 2.
myGui.Fade(4, false); // fades out with a speed of 4.



I did this without the editor so syntax errors are possible.

T-Pr

thank you very very much :), i changed it a little bit by using your codes in a way ;,


Code: ags



function room_FirstLoad()
{

int trans = gYazi1.Transparency;
while (trans > 0) {
  trans--;
  gYazi1.Transparency = trans;
  Wait(1);



}
  
while (trans < 100) {
    trans++;
    gYazi1.Transparency = trans;
    Wait(1);
    

}

player.ChangeRoom(8, 0, 0);
}




and it works , thanks a lot again :D .

SMF spam blocked by CleanTalk