Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Wretched on Fri 24/03/2006 15:11:11

Title: Suggestion - Dynamic Sprite CreateFromBackground
Post by: Wretched on Fri 24/03/2006 15:11:11
Would it be possible to add a transparency colour to the CreateFromBackground function, or just use (255,0,255) as a transparency? So that this colour is masked out of the created sprite.
I was trying to create some procedural sprites and hit a barrier without this option.
Title: Re: Suggestion - Dynamic Sprite CreateFromBackground
Post by: Radiant on Fri 24/03/2006 15:15:47
Seconded. Personally I would prefer being able to select a transparent pixel.
Title: Re: Suggestion - Dynamic Sprite CreateFromBackground
Post by: Pumaman on Fri 24/03/2006 18:30:05
I'm not sure in what context this would be useful? The room background image doesn't tend to have transparent areas?
Title: Re: Suggestion - Dynamic Sprite CreateFromBackground
Post by: Kweepa on Fri 24/03/2006 18:38:47
For example - a particle system:
RawSaveScreen
Clear the screen to transparent
Draw particle system
Create a particle system sprite from the background
RawRestoreScreen
Set object sprite to the particle system sprite, which can then be drawn sorted (characters in front and behind).
Title: Re: Suggestion - Dynamic Sprite CreateFromBackground
Post by: Wretched on Fri 24/03/2006 19:01:34
I was going to use one of the spare background frames to generate an inventory icon with flies flying around on it, so needed transparency. Got around it with some GUI gigery-pokery though. Still it would be quite a powerful addition imo.
Title: Re: Suggestion - Dynamic Sprite CreateFromBackground
Post by: SSH on Sat 25/03/2006 08:48:43
Actually, certain colours used as a background ARE already transparent, its just that this is undocumented! I use this in my SpriteFonts moudle. On an 8-bit background, I think it is colour 0. On 16-bit, its another one (Magenta, maybe),
Title: Re: Suggestion - Dynamic Sprite CreateFromBackground
Post by: Wretched on Sat 25/03/2006 10:21:25
SSH, yes that was the first thing I tried, using (255,0,255), but it didn't work also tried (255,255,255).
Title: Re: Suggestion - Dynamic Sprite CreateFromBackground
Post by: SSH on Sat 25/03/2006 16:28:33
Here's the code in SpriteFont. NB, with  the latest beta you can tell in the editor the bit depth of a BG. Still no way to tell in a game, I think, though...


DynamicSprite *SpriteFont::TextOnSprite(String t) {
  int x=0;
  int y=0;
  int w=this.GetSpriteTextRawWidth(t);
  int h=this.GetSpriteTextRawHeight(t);
  DynamicSprite *dspr;
  RawSaveScreen();
  if (system.color_depth==8) {
    RawClearScreen(0); // Col 0 is transparent
  } else {
    RawClearScreen(63519); // Pure Magenta is transparent colour
  }
  this.TextOnBackground(x, y, t, false, 0);
  dspr=DynamicSprite.CreateFromBackground(GetBackgroundFrame(),x,y,w,h);
  RawRestoreScreen();
  return dspr;
}
Title: Re: Suggestion - Dynamic Sprite CreateFromBackground
Post by: Wretched on Sun 26/03/2006 10:14:20
Thanks, SSH, the subtle difference is that I was using a background with (255,0,255) already on it which does not give transparent. If I use a rawdrawrectangle with (255,0,255) ,colour then it does act as transparent.
So problem solved.