I'm currently creating a platforming game, where when the player takes a hit or falls outside the layout, 1 is subtracted from the instance variable lives, of the player, and then I call a function so that if lives = 3, set it to the full heart, 2, set it to one quarter taken away, as such:
I had the code to subtract from and add to the instance variable when there's a collision with the related object (I tried having the subtract/add 1 to the lives variable within the functions themselves, but that didn't work either for me)
Similar I have a gainLives method, that on collision with a heart pick up, add 1 to the players lives, and do the same with the animation.
But the problem is, it's quite random when it decided to follow these. The player will walk into a enemy, and flash like they took damage, but the health won't change, they'll walk into the enemy again, and it'll go down by one. The same happens when picking up health. I was wondering if it would be better to use global variables instead, or if there's a different solution I don't know off (I've only found Construct recently as it's the program I need to use for an assignment).
Any help is greatly appreciated