Fading away to transparent

Started by Babar, Wed 24/12/2008 14:55:02

Previous topic - Next topic

Babar

I have a number of objects on-screen that I want to fade away from totally visible to invisible in a certain amount of time. So I checked up Object.Transparency(...) in the help file, and found some code for doing exactly what I want (with editting the object[0] to the name of my object and all):

int trans = object[0].Transparency;
while (trans < 100) {
  trans++;
  object[0].Transparency = trans;
  Wait(1);
}

Problem is that this code doesn't fix what it claims to fix in the help file (using a loop with object[0].Transparency++; is not recommended as it will probably end too quickly). What I get is a wait of about a 100 cycles (or more when I increased the value in the wait), and then suddenly the object becomes invisible.


Is there any way to have a gradual change from visible to invisible for an object? Thanks!
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Pumaman

What colour depth is your game? Transparency isn't supported with 256-colour images.

Babar

#2
No, the game is 32bit. It is using DirectDraw 5, and I happen to have 4Gb of RAM (if any of that is relevant).
I imported the sprites in 32bit also (I am pretty sure, because it asked if I wanted to use the alpha channel in it when I imported it).

I actually have several objects simultaneously fading away, but I don't think that would be the problem, because I tried it with only 1 of the objects, and the result is the same. A long wait, and then quick disappearing.

I sent it to someone else to test, but they had the same result.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Pumaman

Hmm, that's rather strange. Do you have any other transparency effects in your game? If so, do they work? Which version of AGS are you using? Direct3D or DX5 driver?

Can you upload a game that demonstrates the problem?

Babar

No other transparency effects, although the sprite in question has an alpha channel (again if that is relevant).
Here is an example game.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Pumaman

Ah yes, that is relevant. Fixed transparency isn't supported with alpha-channel sprites when using the DX5 driver. You can try switching to D3D, which should get it working.

Babar

#6
Thanks for telling me! Is there any other things like that with alpha channel? I had been having problems with .Tint(), but I had put that down to my own sloppy coding.


EDIT: Actually, no....still doesn't work. I switched from the default DirectDraw 5 to Direct3D 9, and it doesn't seem to have improved any. The same link in the above post applies.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Babar

Setting the transparency to 50 or 80 or 90 directly (without any incrementing loop) doesn't work either. And I amusing D3D now....so I don't know what the problem is. Help!
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Babar

The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Gilbert

Well, I've tried importing another two sprites, one without alpha-channel and one with alpha channel.

The fading works only on the one without alpha channel, so it seems that even when you use D3D9 the Transparency still only works with non-alpha blended sprites.

BTW, @CJ, from the manual:
QuoteNOTE: Transparency currently only works in hi-color games, and the object must have been imported in hi-colour for the transparency to work.

Maybe it should be updated a bit? To something like:
QuoteNOTE: Transparency currently only works in hi-color or true-color games, and the object must have been imported in hi-colour or true-color for the transparency to work. Note also that if the sprite have an alpha channel, this property won't work.


Babar

How very disappointing. Oh well. Thanks for the clarification again.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Pumaman

Sorry, I forgot about this thread. Yes, I also forgot that even with D3D you can't currently mix alpha-channel and fixed transparency. This is something that needs to be addressed in a future release, however.

Gilbot: good point, thanks -- I'll update the manual to mention this.

SMF spam blocked by CleanTalk