My_old_list = "replace some data at position 0 in list" You could even assign the number 0 to new variable, then use that new variable to access the list.ĭs_list_add(my_old_list, "some_more_data") The data structure still exists, and you can still access it with the id of 0. NOTE : The important bit is, even if the variable holding the id of the data structure is destroyed, the data structure is still in memory, and can even be re-accessed if you still know what its id was. It appears as if you have lost track of the DS.and maybe it has been destroyed.but wait. Let's say the variable my_list was in an instance that you created in room0, and then you moved to room1 and the instance was destroyed, along with its variable "my_list". So now, we have a ds_list floating around in memory that GMS is keeping track of internally, and which you can access using the id/index of 0.Īnd it will add it to the list that you created above. My_list = ds_list_create() // my_list now equals 0 ( for example ). Yeah, so what happens is, when you create a ds_list for example, you get in return an integer id that you need to keep track of. On a game_restart, when everything is thrown away and started from the beginning, you definitely would have to destroy those lists because you game would be restarting from the original initialisation room (in my example above) and you would get memory leaks.Ĭlick to expand.The variable that was indexing the ds_list indeed disappears, however the content does not. If you have a global persistent object that you only create once at the start of the game in an initialisation room, and it is holding the ds_lists, you can probably get away with not having to delete them and re-create them on a room_restart. I would personally recommend not using room_restart and game_restart, you should control the flow of your game manually using room_goto() most of the time.ĭepending on your game of course. So you should definitely make sure that you are always cleaning them up, even on room_restart and game_restart (generally speaking). The data structures in Game Maker are dynamically allocated and do not delete themselves. Click to expand.Ah.if only this were true, unfortunately it doesn't apply to data structures (anything starting with ds_ )
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |