Character Transparency failing to update issues

Started by thezombiecow, Thu 12/03/2009 14:11:14

Previous topic - Next topic

thezombiecow

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: ags

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


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

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


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: ags

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


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.

Vince Twelve

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: ags
//global
int dantrans;

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

thezombiecow

#2
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?

Gilbert

Hmmm When bFadein is set to true, did you set the value of dantrans to match the transparency of the character accordingly?

thezombiecow

#4
Quote from: Gilbet V7000a on Fri 13/03/2009 00:50:52
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: ags

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



??

:)

Gilbert

What I meant was, where do you set bFadeIn to true in your codes? Did you write something like
Code: ags
iDanTrans=cDan.Transparency;

there?

thezombiecow

Aaah I see. Yes, I've tried setting it all over the place to be honest - it doesn't get actioned...

Pumaman

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?


Pumaman

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.

QuoteSince 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?

SMF spam blocked by CleanTalk