Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: idiotbox on Wed 26/10/2005 20:21:00

Title: Changing GUI Button sprites
Post by: idiotbox on Wed 26/10/2005 20:21:00
Okay, I have a healthbar in my GUI. Now I've looked in the manual but can't find what I want. Is there a way to change the sprite on the button when my health int decreases?

Something like

if (health==90){
Ã,  Ã,  //change image//
}

etc.
Ã,  Ã, 
Title: Re: Changing GUI Button sprites
Post by: Ashen on Wed 26/10/2005 20:30:16
Button.NormalGraphic property (http://www.adventuregamestudio.co.uk/manual/Button.NormalGraphic.htm) should be what you're after. (And possibly MouseOverGraphic and  PushedGraphic too.)

So:

if (health == 90) {
  btnHealth.NormalGraphic = 54; // where 54 is the spriteslot of the new image
}

//etc


However, depending on what exactly is on the graphic there may be another way to do it. For example, if the button is a bar that you want to shrink or grow depending on your health, you could use the ClipImage property, and just change the button's size accordingly.
Title: Re: Changing GUI Button sprites
Post by: idiotbox on Wed 26/10/2005 20:36:41
Thanks a lot. I was just confused earlier.
Title: Re: Changing GUI Button sprites
Post by: RickJ on Wed 26/10/2005 20:37:41
You may want to lookup Button.ClipImage in the manual also.   Set this property to true and then you can just resize the button to implement a bar graph.
Title: Re: Changing GUI Button sprites
Post by: idiotbox on Wed 26/10/2005 21:12:13
It is now saying btnHealth is an undefined token and
I even put the int on the top of global script and it says it's already been defined. Am I doing something wrong?
Title: Re: Changing GUI Button sprites
Post by: Ashen on Wed 26/10/2005 21:58:55
No, I did - kind of. I should've mentioned that btnHealth needs to be replaced with the script name of the button you want to change the graphic of. You can check (or set, if needed) the script name on the GUI editor window. Sorry about that.