Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: jerakeen on Thu 15/01/2009 13:23:51

Title: Problem with transparency drawig a sprite onto another
Post by: jerakeen on Thu 15/01/2009 13:23:51
When i draw sprites using transparency onto another, if the second one has a image background it works all right and use transparency.
But when i clear the second sprite with clear() or clear(COLOR_TRANSPARENT), the sprites i draw has transparent colour instead being transparent.

All the sprites, background etc has the same color depth
I use AGS v3.1.1


    DynamicSprite * sprParticleSystem = DynamicSprite.CreateFromBackground();
    surface = sprParticleSystem.GetDrawingSurface();
    surface.Clear();

    DynamicSprite  *sprite = DynamicSprite.CreateFromExistingSprite (18, false);
    surface.DrawImage (5, 5, sprite.Graphic, 40);
    sprite.Delete();

    surface.Release();

    Overlay * ovrParticleSystem = Overlay.CreateGraphical(0, 0, sprParticleSystem.Graphic, true);

   ...

   sprParticleSystem.Delete();
   ovrParticleSystem.Remove();


WhatI'm doing wrong?

EDIT:

This is an example of what im doing

(http://www.2dadventure.com/ags/Fire_on_sprite.png)     (http://www.2dadventure.com/ags/Fire_bg.png)

the first image shows when i draw sprites transparent into another sprite cleared to transparent colour

the second one shows when i draw sprites transparent into other sprite with background


Please tell me something.

I'm wrong posting here, and should post on technical forum?

Title: Re: Problem with transparency drawig a sprite onto another
Post by: Pumaman on Mon 26/01/2009 20:10:49
Are you using any sprites with alpha channels? What colour depth is the game?
Title: Re: Problem with transparency drawig a sprite onto another
Post by: jerakeen on Mon 26/01/2009 20:31:30
I tried with sprites in 32 color depth without alpha channels, and game at 32 depth too and this is what happens.

Then i tried sprites with alpha channel and without using transparency and happens the same, this pink colour again. (sprites and game at 32 color depth)

So i don't understand what happens.



Title: Re: Problem with transparency drawig a sprite onto another
Post by: Pumaman on Mon 26/01/2009 20:34:42
It's probably the transparency setting, whereby it's trying to draw 40% transparent pixels against the transparent colour (which is pink #FF00FF). If you remove the ",40" from the DrawImage command, do the pink areas disappear?
Title: Re: Problem with transparency drawig a sprite onto another
Post by: GarageGothic on Mon 26/01/2009 20:48:08
CJ, in relation to this, I was wondering: How much work would it take you to implement alpha channel support for DrawingSurface routines, so that using DrawImage on a cleared surface with transparency or an alpha channel sprite would actually result in a DynamicSprite with an alpha channel rather than the effect we see in this example? Personally I would find it a very useful feature.
Title: Re: Problem with transparency drawig a sprite onto another
Post by: jerakeen on Mon 26/01/2009 20:49:26
Yes Pumaman, it draws the sprite opaque, exactly as i imported into the sprite editor