instance_create(x,y,<object>)

Drag & Drop equivalent : GM023

 

X = Horizontal position on screen in pixels.

Y = Vertical position on screen in pixels.

<object> = The object you want to display.

 

Example:

instance_create(30,30,obj_player);

 

This will create an instance of <object> at position X and Y. X and Y are screen position in pixels and can be anywhere, outside the current view, even outside the physical screen size, these are especially good for creating objects that start outside the screen area and then come into view.

 

For example, the default room size that Game Maker creates is 640 x 480, instance_create(0,0,obj_enemy) will create obj_player at the top-left hand corner of the screen, while instance_create(-100,0,obj_enemy) will create the object 100 pixels to the left outside of the current screen, this is handy if you want your enemy to 'fly in' (a bit like R-Type).

 

You're not just limited to absolute co-ordinates (numbers), you can create an object relative to another object, e.g. say for example you wanted something to appear next to your player, no matter where on the screen he is, you could have something like:

 

instance_create(obj_player.x+10,obj_player.y+10,obj_fairy);

 

This will create the object 'obj_fairy' 10 pixels to the right and 10 pixels down from the sprites origin (default is the top-left of the sprite). You can even create objects appear at a random position on the screen:

 

instance_create(floor(random(room_width)),

  floor(random(room_height)),obj_bullethole);

 

Revision #2