Suggestion - Dynamic Sprite CreateFromBackground

Started by Wretched, Fri 24/03/2006 15:11:11

Previous topic - Next topic

Wretched

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.

Radiant

Seconded. Personally I would prefer being able to select a transparent pixel.

Pumaman

I'm not sure in what context this would be useful? The room background image doesn't tend to have transparent areas?

Kweepa

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).
Still waiting for Purity of the Surf II

Wretched

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.

SSH

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),
12

Wretched

SSH, yes that was the first thing I tried, using (255,0,255), but it didn't work also tried (255,255,255).

SSH

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...

Code: ags

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;
}
12

Wretched

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.

SMF spam blocked by CleanTalk