instance_count

Returns the total number of instances currently active in the room.

Syntax:

instance_count


Returns: Real


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.


Example:

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

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


Back: Instance Functions
Next: instance_id
© Copyright YoYo Games Ltd. 2018 All Rights Reserved