C
CXXXV
Guest
Say in my room1 i have object1 at (10,10), then i move it to (10,15).
How do i make my object1 stay at (10,15) after i change room and back?
How do i make my object1 stay at (10,15) after i change room and back?
ini_open("Save.ini");
ini_write_string("object_info", "object", object_get_name(OBJECT_TO_SAVE));
ini_write_real("object_info", "x", x);
ini_write_real("object_info", "y", y);
ini_close();
ini_open("Save.ini");
var obj = ini_read_string("object_info", "object", "");
var xx = ini_read_real("object_info", "x", 0);
var yy = ini_read_real("object_info", "y", 0);
if obj != ""
{
switch(obj)
{
case "obj_Player": instance_create(xx, yy, obj_Player); break;
// add more cases for each object
}
}
But if i use persistent the object would appear in the next room no?Enable the objects persistence checkbox.
The alternative suggested by Nocturne assumes that you delete the instance when leaving the room, there are benefits to this.
one benefit is closing the game then coming back to it. like real time save/load function!
I have to do the hard work eh. How do i iterate all object in my room?Store the position in a file. Easiest is to store the object and the position to an ini file, but you can also use text files, binary files, buffers, or ds_maps.
The benefit of this over persistence is that you don't need to worry about the instance being "carried over" to the wrong rooms, and you can also close and restart the game and the position will still be saved.
with (all) {
//Do something
}
What's the downside with room_persistent?If you want the room's state to remain as-is after returning from another room, use room persistence instead of object persistence. Go to the Settings tab and check the Persistent checkbox. Or alternatively use room_persistent.
So if I were trying to save my character's place in a room so that there still there when I get back should I do something like this?