Gui.Y and/or Transparency issues with text [SOLVED]

Started by Ultra Magnus, Mon 24/08/2009 04:08:14

Previous topic - Next topic

Ultra Magnus

I'm having trouble with text showing up and acting accordingly when I use gui.Y and/or gui.Transparency.
Here's what I've tried so far...


Idea #1)
I started with a little text box (gFrame) sitting below the screen with a label (lblSubtitle) saying "Day One", and this code...
Code: ags

function room_AfterFadeIn()
{
 while (gFrame.Y>=356) 
 {
  gFrame.Y-=5;
  Wait(1); 
 }
}

gFrame moved up from below the screen as it should, but the text didn't appear until after it had stopped.
I figured this was because the engine doesn't want to waste resources by writing text while it's off-screen, so...


Idea #2)
Move lblSubtitle to a different gui (gFrameover) and have it fade in and out over gFrame after it's stopped moving.
Code: ags

 while (gFrame.Y>=356) 
 {
  gFrame.Y-=5;
  Wait(1); 
 }
 int trans=gFrameover.Transparency;
 while (trans>0)
 {
  trans--;
  gFrameover.Transparency=trans;
  Wait(1);
 }
 Wait(200);
 while (trans<100)
 {
  trans++;
  gFrameover.Transparency=trans;
  Wait(1);
 }

gFrame moved as it should, and then nothing. No text, and the game hung as if I had called Wait(∞).


Idea #3)
The gFrame.Y code seemed to work well enough, so I tried adjusting the gFrameover.Transparency code to be more like it.
Code: ags

 while (gFrameover.Transparency>=1)
 {
  gFrameover.Transparency-=1;
  Wait(1);
 }
 Wait(200);
 while (gFrameover.Transparency<=99)
 {
  gFrameover.Transparency+=1;
  Wait(1);
 }

Still nothing. Same result as #2. However, when I change it to...
Code: ags

 while (gFrameover.Transparency>=5)
 {
  gFrameover.Transparency-=5;
  Wait(1);
 }
 Wait(200);
 while (gFrameover.Transparency<=95)
 {
  gFrameover.Transparency+=5;
  Wait(1);
 }

...the text finally shows up, but it instantly flashes on and off instead of fading. I tried changing the instances of Wait(1) to a higher number (in case it was working, but just going too fast), but that only makes it take a bit longer before the text still flashes on and off.


Also, I found an old thread where people said that it might have been the Wait(200) in the middle screwing it up, so I tried all of the above codes using SetTimer(20, 200) instead (with the latter part of the code in rep_exec under an if (IsTimerExpired(20)) clause), but that gave the same results for each of them.


Any ideas how I can fix this?

Thanks in advance for any help.
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.

tzachs

You can download the tween module, see it
here

Then you can simply write something like:
Code: ags

float secondsToMove = 1.5; //Change to the number of seconds you want the gui to move & change transparency
gFrame.TweenPosition(secondsToMove, gFrame.X, 356, eLinearTween, eNoBlockTween);
gFrame.TweenTransparency(secondsToMove, 100, eLinearTween, eNoBlockTween);


Khris

I tried your first method with a 640x400/16bit game with both DirectDraw and Direct3D.
The text was always visible from the start just fine, no matter which mode or what .Transparency.

Ultra Magnus

Quote from: KhrisMUC on Mon 24/08/2009 19:56:00
I tried your first method with a 640x400/16bit game with both DirectDraw and Direct3D.
The text was always visible from the start just fine, no matter which mode or what .Transparency.

Any idea why it's not working for me?
I tried it in 16 and 32 bits, with DirectDraw and Direct3D, both through the editor and compiled, and it's still giving the same result.

What's more is if I put...
Code: ags

 while (gFrame.Y>=356) 
 {
  gFrame.Y-=5;
  Wait(1); 
 }
 Wait(100);

...then the text stays blank until after the wait period, the same way as I mentioned earlier with the transparency attempt.

Quote from: tzachs on Mon 24/08/2009 11:59:06
You can download the tween module
Thanks, I'll look into that.
I'd rather not have to use a plugin just to make a game do what it's supposed to be doing in the first place, but I'll try it if nothing else works.
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.

Ultra Magnus

#4
When player interface is disabled, GUIs should: Hide all their controls

I didn't think this applied to labels. But why wouldn't it? ::)

For anyone who cares, it can be changed at runtime with SetGameOption(OPT_WHENGUIDISABLED, x);
I don't mean to sound bitter, cold, or cruel, but I am, so that's how it comes out.

I'm tired of pretending I'm not bitchin', a total frickin' rock star from Mars.

SMF spam blocked by CleanTalk