I was coding a game and when I was setting a max for the bar, my game crashed. What is the fix for this and how do I fix it? Thanks.
The issue is here:
That “game… Action!” Function sets the “statusbar” variable to a statusbar sprite. However, in the way the code is ordered, you set the bar’s max before you actually define the sprite, causing the classic “failed cast on null” crash. Just add the block that sets the max value to inside the function (before the block that sets the max), that should do fine!
(Also the “change statusbar value by” blocks in the game update loop are changing the statusbar by a positive value, im pretty sure you want to change it by a negative value. Just do “-10” instead of “10” for example.)
you’re setting the max before you define the statusbar since the initialisation function is after the set max block
Ok… I see now. Where do I put the block. I know you said put it in the function, but where in the function?
