Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: KodiakBehr on Thu 13/10/2011 20:50:11

Title: Changing GUI Background Color
Post by: KodiakBehr on Thu 13/10/2011 20:50:11
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.
Title: Re: Changing GUI Background Color
Post by: Khris on Thu 13/10/2011 20:54:42
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.
Title: Re: Changing GUI Background Color
Post by: KodiakBehr on Thu 13/10/2011 20:58:30
Yeah, that was my fall-back approach.  Oh well, not a big deal.  Thanks.
Title: Re: Changing GUI Background Color
Post by: monkey0506 on Fri 14/10/2011 04:48:13
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).
Title: Re: Changing GUI Background Color
Post by: KodiakBehr on Sat 15/10/2011 02:15:48
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.
Title: Re: Changing GUI Background Color
Post by: Khris on Sat 15/10/2011 04:21:03
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.
Title: Re: Changing GUI Background Color
Post by: monkey0506 on Sat 15/10/2011 05:08:58
Rather than use multiple buttons why not use one and change the NormalGraphic?
Title: Re: Changing GUI Background Color
Post by: Calin Leafshade on Sat 15/10/2011 05:25:33
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
Title: Re: Changing GUI Background Color
Post by: KodiakBehr on Sat 15/10/2011 06:40:59
Thanks guys.