Game authors and players, please read this thread!

Author Topic: Character Transparency failing to update issues  (Read 661 times)  Share 

I recently updated to 3.1.2 SP1, and I've been noticing some issues relating to character transparency. I haven't been able to thoroughly look into this yet, so it might be that I'm just overlooking something.

Previous versions of AGS 3+ had a weird fade in/ out effect where the sprite would bleach out to white, before fading. It looked kind of funky. The latest version fades in/ out as expected.

However, I've ceuurently got two issues that have suddenly sprung out of nowhere. Firstly, in rep_exec:

[code]
        if (bFadeOut)
   {
      if (cDan.Transparency < 100) {cDan.Transparency++;}
      if (cDan.Transparency >= 99)
      {
         // do whatever!
          bFadeOut = false;
       }
   }
[/code]

Works fine! cDan fades out nicely. But in reverse:

[code]   
   if (bFadeIn)
   {
            if (cDan.Transparency > 0) {cDan.Transparency--;}
      if (cDan.Transparency <= 0)
      {
         // do whatever!
          bFadeIn = false;
       }         
   }
[/code]

This way round the code seems to hang - it won't take anything off cDan.Transparency whatsoever.

Ok, so possibly my fault. I'm looking into it, but there's nothing obvious like cDan.Transparency = 100; in rep_exec_always or anything. This one's odd too:

[code]
if (whatever)
{
   // do stuff..
  // do more stuff...
  // do a bit more stuff....
  oDan.Visible = false;
  cDan.Transparency = 0;
}
[/code]

Ok, this flips from a Dan object to Dan the character after a cutscene.

In the previous cut of AGS it'd happen simultaneously, so the transition was seemless. Since the update, what seems to happen is that oDan.Visible = false doesn't take place until after we drop out of the rep_exec loop (after some Wait(x)s etc). So the two are on screen at the same time, until we drop out.

This is all code that pre-update was working fine... is this a known issue somewhere that I've missed? Something relating to changing character transparency properties in a loop?

Any advice would be awesome.
« Last Edit: 12 Mar 2009, 14:15 by thezombiecow »

Vince Twelve

  • Why can't I hold all these trophies?
    • Best Innovation Award Winner 2006, for 'What Linus Bruckman Sees When His Eyes Are Closed'
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
  • Vince Twelve worked on a game that was nominated for an AGS Award!Vince Twelve worked on a game that won an AGS Award!
Re: Character Transparency failing to update issues
« Reply #1 on: 12 Mar 2009, 14:17 »
The first problem, involving the use of cDan.Transparency-- won't work because of the way AGS rounds Transparency, I believe.  Instead, create a variable to store the transparency, and decrement and set off of that.

[code]//global
int dantrans;

//rep_exec
        if (bFadeIn)
   {
            if (cDan.Transparency > 0)
                {
                        dantrans--;
                        cDan.Transparency=dantrans;
                }
      if (cDan.Transparency <= 0)
      {
         // do whatever!
          bFadeIn = false;
       }         
   }
[/code]

Re: Character Transparency failing to update issues
« Reply #2 on: 12 Mar 2009, 20:29 »
Hmmmn. Not quite - it's marginally better but still not working - he jumps from being 100% transparent to 0%, so just blinks in suddenly.

And the fade down works perfectly, which make it even more odd now I think about it...

EDIT: aaah, but if I whip cDan.Transparency = dantrans out of the if (bFadeOut) condition and pop it in the main rep_exec loop, it works perfectly. Thanks! So is there some issue with Character Transparency only being updated in the main rep exec loop? And if so, is it that it can cope with going up, but not down somehow?
« Last Edit: 12 Mar 2009, 20:37 by thezombiecow »

Iceboty V7000a

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
    •  
Re: Character Transparency failing to update issues
« Reply #3 on: 13 Mar 2009, 00:50 »
Hmmm When bFadein is set to true, did you set the value of dantrans to match the transparency of the character accordingly?

Re: Character Transparency failing to update issues
« Reply #4 on: 13 Mar 2009, 11:11 »
Hmmm When bFadein is set to true, did you set the value of dantrans to match the transparency of the character accordingly?

I'm not quite sure what you mean, but I'm fairly sure yes.

Having looked into the issue a little more, I think character.Transparency isn't getting updated by AGS in the same way as previous versions:

As such, the code above needs to be re-written as:

[code]
function room_RepExec()
{

  if (bFadeIn)
  {
       if (cDan.Transparency > 0)
      {
        iDanTrans--;
      }
         
       if (cDan.Transparency <= 0)
       {
        // do whatever!
   bFadeIn= false;   
   }
            
      
  }

  // update Dan's Transparency.
  cDan.Transparency = iDanTrans;

} // rep_exec
[/code]


??

:)
« Last Edit: 13 Mar 2009, 11:14 by thezombiecow »

Iceboty V7000a

  • Local Moderator
  • * KILL* * KILL * * KILL *
    • Lifetime Achievement Award Winner
    •  
Re: Character Transparency failing to update issues
« Reply #5 on: 13 Mar 2009, 12:26 »
What I meant was, where do you set bFadeIn to true in your codes? Did you write something like
[code]iDanTrans=cDan.Transparency;[/code]
there?

Re: Character Transparency failing to update issues
« Reply #6 on: 13 Mar 2009, 15:02 »
Aaah I see. Yes, I've tried setting it all over the place to be honest - it doesn't get actioned...

Pumaman

  • Creator of AGS
  • Administrator
  • Mittens TRAITOR
  • I sense danger.
    • Lifetime Achievement Award Winner
    •  
Re: Character Transparency failing to update issues
« Reply #7 on: 13 Mar 2009, 23:22 »
The Transparency property has always had slightly strange behaviour like this, and hasn't changed in the latest version. What version were you using before you upgraded to 3.1.2 SP1?

Re: Character Transparency failing to update issues
« Reply #8 on: 13 Mar 2009, 23:24 »
Um... looks like plain 3.1.

Pumaman

  • Creator of AGS
  • Administrator
  • Mittens TRAITOR
  • I sense danger.
    • Lifetime Achievement Award Winner
    •  
Re: Character Transparency failing to update issues
« Reply #9 on: 13 Mar 2009, 23:35 »
Ok -- well, the behaviour of the Transparency property hasn't changed between 3.1 and 3.1.2. The only significant change is that transparency is now honoured with alpha-channeled sprites, but if you're not using alpha channels then this shouldn't affect you.

Quote
Since the update, what seems to happen is that oDan.Visible = false doesn't take place until after we drop out of the rep_exec loop (after some Wait(x)s etc). So the two are on screen at the same time, until we drop out.

That certainly shouldn't be the case -- can you try using the debugger to step through those lines of script and make sure that it's definitely calling the lines of code that you expect it to?