Is there a way to display in the inventory - below the money image I have, the number of coins I have?
When I managed to do is when I'll look at they I'm displaying the number of coins but it's not proffesional enough.
Thank you!
This one's a bit more complicated.
DynamicSprite *inv_money_sprite;
int inv_money_sprite_sprite;
void updateMoneySprite() {
// change these if necessary
int w = invCustomInv.ItemWidth, h = invCustomInv.ItemHeight; // invCustomInv: inventory window
InventoryItem *i = iMoney; // iMoney: inventory item representing money
int m = money; // money: global variable storing amount of money
int font = eFontFont0; // font used for amount
if (inv_money_sprite == null) {
inv_money_sprite = DynamicSprite.Create(w, h);
inv_money_sprite_sprite = i.Graphic;
}
DrawingSurface *ds = inv_money_sprite.GetDrawingSurface();
ds.Clear(0);
ds.DrawImage(0, 0, inv_money_sprite_sprite);
ds.DrawingColor = 15;
int ww = GetTextWidth(String.Format("%d", m), font);
ds.DrawString(w/2-ww/2, h - 12, font, "%d", m);
ds.Release();
i.Graphic = inv_money_sprite.Graphic;
UpdateInventory();
}
Put this at the top of the global script.
Look at the first few lines, they use some values I guessed at. Change them if necessary.
In order to use this function, just call it after you have changed the amount of money the player has.
Example:
// player finds 10 dollars:
money += 10;
updateMoneySprite();
If you need it in room scripts, add this line to GlobalScript.ash:
import updateMoneySprite();
I'm sorry for the delayed response - I had some problem with my computer...
Thank you very much!
It opened my eyes to the possibilities in AGS :shocked: