GM: instance number

From GMpedia.org Wiki

Jump to: navigation, search
The correct title of this article is instance_number(obj). It appears incorrectly here because of technical restrictions.
The correct title of this article is instance_number(). It appears incorrectly here because of technical restrictions.


Arguments

obj = The object you want to find how many of there is.

Limitations

none

Note: Please remove limitations and port them in the "Remarks" section at the end of the article.

This function can be used to check if there are any instances of an object left in the room.

[edit] Example

This is particularly useful if you have a number of instance of an enemy and you want the player to move to the next level after he's destroyed all the enemy. You can also use multiple checks for different objects.

if (instance_number(obj_enemy01) = 0) and (instance_number(obj_enemy02) = 0)
{
 // Goto the next level / room;
}
This article was originally found at the Game Maker Knowledge Base, contributed by nickydude.
See the talk page for details
Personal tools