Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: deltamatrix on Wed 04/04/2007 14:48:15

Title: Can't update GUI Labels
Post by: deltamatrix on Wed 04/04/2007 14:48:15
I have the following code in the global script.
 
  lblHealth.Text = String.AsInt(heroHP);
  lblMonsterHealth.Text = String.AsInt(enemyHP);

Unfortunately, I get the following compilation error:

In: 'Global script'

Error (line 14): must have an instance of the struct to access a non-static member

How do I fix this? I cannot find any documentation about this.
Title: Re: Can't update GUI Labels
Post by: Khris on Wed 04/04/2007 15:25:18
String.AsInt is for converting a string to an int, e.g.:
String a="333";
int b = a.AsInt;  // no brackets, too, btw

You'll want:
  lblHealth.Text = String.Format("%d", heroHP);

There is a pretty recent thread (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=30729.0) explaining this, too.
Title: Re: Can't update GUI Labels
Post by: deltamatrix on Wed 04/04/2007 17:04:46
Silly me.

Thanx