room_instance_add

Adds an object instance at a given position to a given room.

Syntax:

room_instance_add(ind, x, y, obj);


Argument Description
ind The index of the room to add an object instance to.
x The x position of the new instance.
y The y position of the new instance.
obj The object to add an instance of.


Returns: Real


Description

With this function you can add an instance into any room other than the current one and at any position within that room. The function returns the unique id of the instance which can then be used in further function calls to set properties etc... of that instance, but only once the game has entered the specified room. If you wish to create an instance in the current room you should be using the function instance_create.


Example:

global.rm = room_add();
room_assign(rm_Base, global.rm);
room_instance_add(global.rm, 100, 100, obj_Player);

The above code will add a new room to the game and then copy the contents of the room indexed as "rm_Base" into it. It will then add an instance of the object "obj_player" at the position 100,100 of this new room.


Back: Rooms
Next: room_instance_clear
© Copyright YoYo Games Ltd. 2018 All Rights Reserved