Hi all -
This is a very simple but annoying issue. I'm trying to remove the default "button" graphics from the buttons on a GUI and replace them with a transparent sprite that has the button's description on it. Here is the code I'm using:
DynamicSprite *bfast = DynamicSprite.Create(btnFast.Width, btnFast.Height);
DrawingSurface *dfast = bfast.GetDrawingSurface();
dfast.Clear();
dfast.DrawingColor = player.SpeechColor;
dfast.DrawString(0, 0, Game.NormalFont, "Fast");
dfast.Release();
btnFast.NormalGraphic = bfast.Graphic;
That code is repeated for each of the buttons, however it doesn't work. The button either retains its original default graphic or (if I delete the button text) it is completely invisible (the GUI and buttons are still enabled correctly, just invisible). This seems like a problem with a simple solution, but I'm not sure why my code isn't working.
Thanks.
I havent worked a lot with Dynamic Sprites or Drawing Surfaces yet, however I can suggest one thing to try.
Declare the bfast outside of the function where this is running. I have a feeling you are creating the bfast sprite and when it finishes the code the bfast sprite is going away and therefore the btnfast graphic is reverting back to the basic.
at the top of the module
DynamicSprite *bfast;
then change line 1 to be:
bfast = DynamicSprite.Create(btnFast.Width, btnFast.Height);
That did it. Simple, as I expected.
Thanks.