08.11.2012 Views

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

Designing Games with Game Maker - YoYo Games

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

instance_count* Number of instances that currently exist in the room.<br />

instance_id[0..n-1]* The id of the particular instance. Here n is the<br />

number of instance.<br />

Note that the assignment of the instances to the instance id's changes every step so you<br />

cannot use values from previous steps. Let me give an example. Assume each unit in your<br />

game has a particular power and you want to locate the strongest one, you could use the<br />

following code:<br />

{<br />

}<br />

maxid = -1;<br />

maxpower = 0;<br />

for (i=0; i maxpower)<br />

{maxid = iii; maxpower = iii.power;}<br />

After the loop maxid will contain the id of the unit <strong>with</strong> largest power. (Don't destroy instances<br />

during such a loop because they will automatically be removed from the array and as a result<br />

you will start skipping instances.)<br />

instance_find(obj,n) Returns the id of the (n+1)'th instance of type obj.<br />

obj can be an object or the keyword all. If it does not exist, the special object<br />

noone is returned. Note that the assignment of the instances to the instance<br />

id's changes every step so you cannot use values from previous steps.<br />

instance_exists(obj) Returns whether an instance of type obj exists. obj<br />

can be an object, an instance id, or the keyword all.<br />

instance_number(obj) Returns the number of instances of type obj. obj<br />

can be an object or the keyword all.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!