Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: lafouine88 on Fri 20/09/2024 08:14:06

Title: [SOLVED]pink edging around dynamic sprites
Post by: lafouine88 on Fri 20/09/2024 08:14:06
Hi guys!

I'm using dynamic sprites for my rpg to be able to create differents pieces of stuff.
Thus, I have for each piece of equipment one view for legs, one for body and one for head. I then combine then( code below, but I guess not in cause here).

Problem is, when I combine the 3 views (that look fine on their own) it creates a pink edging around the character and on the shadow.
I found this old thread that might explain the problem, but not really how to solve it :s
https://www.adventuregamestudio.co.uk/forums/beginners-technical-questions/solved-quick-import-sprites-transparency-issue/msg636525850/#msg636525850

Here are a few pictures :

When I use only legs view for my normal view
(https://i.postimg.cc/rF6x5Ygm/img1.png)


When the leg view is combined with body and head-->pink trouble
(https://i.postimg.cc/fRCdnWst/img2.png)

Thanks in advance :)
Title: Re: pink edging around dynamic sprites
Post by: Khris on Fri 20/09/2024 10:31:11
Can you show the code you're using? For instance, is the DynamicSprite created with an alpha channel? Are you clearing the DS using COLOR_TRANSPARENT, etc.

The issue used to be that drawing an alpha channel PNG to a cleared DrawingSurface ruined the transparency because there was no color to blend the semi-transparent pixels with. Afaik this has been resolved though, but I'm not sure.

If you're drawing the three sprites to a new sprite, try creating a copy of the first sprite and drawing the other two to its surface instead.
Title: Re: pink edging around dynamic sprites
Post by: lafouine88 on Fri 20/09/2024 10:45:26
Sorry I forgot the code :


function ChangeNormalView(int base)
{
  int MySpriteNo=0;
  int currentloop=0;
  int currentframe;


  while (currentloop <= 7)//invariable
  {
    currentframe = 0;
    while (currentframe <= 8)
    {
      MySprite2[MySpriteNo] = DynamicSprite.Create(256, 256);
      DrawingSurface *MySurface = MySprite2[MySpriteNo].GetDrawingSurface();
     
      ViewFrame *LegViewFrame = Game.GetViewFrame(base, currentloop, currentframe);
      MySurface.DrawImage(0, 0, LegViewFrame.Graphic);
     
      ViewFrame *ArmorViewFrame = Game.GetViewFrame(base+1, currentloop, currentframe);
      MySurface.DrawImage(0, 0, ArmorViewFrame.Graphic);
     
      ViewFrame *HDViewFrame = Game.GetViewFrame(base+2, currentloop, currentframe);
      MySurface.DrawImage(0, 0, HDViewFrame.Graphic);


      MySurface.Release();
     

      ViewFrame *MyViewFrame = Game.GetViewFrame(52, currentloop, currentframe);
      MyViewFrame.Graphic = MySprite2[MySpriteNo].Graphic;
      MySpriteNo ++;
      currentframe ++;
    }
    currentloop ++;
  }
player.ChangeView(52);
}

Title: Re: pink edging around dynamic sprites
Post by: Snarky on Fri 20/09/2024 10:55:34
Quote from: AGS Manual
Code (ags) Select
static DynamicSprite* DynamicSprite.Create(int width, int height, optional bool hasAlphaChannel)

You have to set hasAlphaChannel to true.
Title: Re: pink edging around dynamic sprites
Post by: lafouine88 on Sat 21/09/2024 21:14:33
Thta was it, thanks a lot :)