health

Global variable for holding the player health.

Syntax:

health;


Returns: Real


Description

This variable is global in scope and is used to hold a numeric value which is usually used for the player health. Bear in mind this is not necessarily always the case - just because it's called "health" doesn't mean it has to be used for the health... it can hold any real or integer value you wish for your game.


Example:

if place_meeting(x, y, obj_Enemy)
   {
   health -= 10;
   if health <= 0 instance_destroy();
   }

The above code checks the current instance to see if there is a collision with the instance of the object indexed in "obj_Enemy", and if there is, it removes 10 points from the global health variable and then checks this value to see if it is less than or equal to 0. If it is the instance destroys itself.


Back: Global Variables
Next: lives
© Copyright YoYo Games Ltd. 2018 All Rights Reserved