Erase a dynamic sprite before creating a new one.

Started by Vincent, Fri 05/05/2017 11:18:01

Previous topic - Next topic

Vincent

Hello guys,

So, I am getting a little stuck on making something pretty simple (it's regarding Dynamic Sprite and Drawing Surface, as usual)
For a testing purpose, I have a Gui with some sliders that handle parameters such as r, g, b, s, l.
Anytime that a slider change I am setting the "SetAmbientTint" with those parameters.
Since now it's working all great, then I have a Dynamic Sprite that create from background and a Drawing Surface that allows me to manipulate it.
So I could make a fully Ambient tint that work also for the room background.
The problem is that anytime I change the slider value the Dynamic Sprite overlaps with the oldest one.
So how can I do that whenever the slider changes erases the old sprite to create a new one?
As I mentioned early it sound like something very simple.

Khris

Why are you even erasing (deleting?) the DynamicSprite? All you need to do is call Clear(color) on the DrawingSurface of your *one* sprite.

Code: ags
DynamicSprite *ambientTint;

// on slider change
  DrawingSurface *ds = ambientTint.getDrawingSurface();
  ds.Clear(the_color);
  ds.Release();

Vincent

I don't know why but I am doing that wrong.
In this way it seems to work, but anytime it get overlap with the old one.
I would like to accomplish something like "SetAmbientTint" which works as it should be.

Code: ags

function Tint()
{
  // on slider change
  spr = DynamicSprite.CreateFromBackground();

  r = SliderR.Value;
  g = SliderG.Value;
  b = SliderB.Value;
  s = SliderS.Value;
  l = SliderL.Value;
  
  SetAmbientTint(r, g, b, s, l);
  
  sur = Room.GetDrawingSurfaceForBackground();
  spr.Tint(r, g, b, s, l); 
  sur.DrawImage(0, 0, spr.Graphic);
  sur.Release();
  spr.Delete();
}

SMF spam blocked by CleanTalk