Changing GUI Background Color

Started by KodiakBehr, Thu 13/10/2011 20:50:11

Previous topic - Next topic

KodiakBehr

Simple lowball question for you all, not covered in the manual --

Is there any way that a GUI Background Color can be changed in the script?  I can't seem to find the appropriate command.

Khris

Looks like you'll have to do it by drawing a rectangle of the desired color onto a DynamicSprite and assigning its .Graphic as the GUI's .BackgroundGraphic.

Seems a bit cumbersome but apparently its the only way. I'm surprised that the Background Color property isn't accessible in script.

KodiakBehr

Yeah, that was my fall-back approach.  Oh well, not a big deal.  Thanks.

monkey0506

If you want a normal background graphic and a background color then it could still be done by drawing the graphic on-top of the rectangle of course. But you'd need to keep an instance of that DynamicSprite* hanging around or it would explode everywhere.

Definitely something that we could look into in the engine, as it's probably already stored in the internal structure, just not exposed (but I don't know that for sure).

KodiakBehr

In this instance, I was using a simple green rectangular GUI as a "health bar" of sorts, adjusting the width to follow a variable.  I wanted to know if there was a way to color the bar differently at different degrees of health. 

Dynamic sprites make sense but I'd have to learn how they work, of course.

Could also, theoretically, use identical GUI's of different colors that go visible or invisible as new variable thresholds are met...but that's really clunky.

A minor thing, but yeah, it'd be great if that was added to the next iteration of the engine.

Khris

Rather than using several GUIs, why not use one GUI with several buttons? Just set them to clip the assigned sprite and reposition and resize them according to the health points.

monkey0506

Rather than use multiple buttons why not use one and change the NormalGraphic?

Calin Leafshade

why not use a dynamic sprite and an overlay?

why not use a single gui and resize it?

why not put a button on your gui and clip the sprite?

ad infinitum

KodiakBehr


SMF spam blocked by CleanTalk