instance_count


Description

With this read only variable you can get a count of all active instances that are in the room. This will include the instance running the code, but does not include those instances that have been deactivated using the instance_deactivate functions. Note that this function will only give you the number of instances at the start of the step, so any changes to the instances in the room made after the step has started will not be taken into consideration.


Syntax:

instance_count;


Returns:

Real


Example:

if (instance_count < 100)
    {
    var dif = 100 - instance_count;
    while (--dif > 0)
        {
        instance_create_layer(random(room_width), random(room_height), "Effects", obj_Star);
        }
    }

The above code will create multiple instances of the object "obj_Star" until the total instance count reaches 100.