Game Development Community

Dynamically loading datablocks during game

by Jon Shattuck · in iTorque 2D · 03/17/2009 (6:27 am) · 5 replies

Our project is going to have a large number of assets and we would like to load datablocks that only contain images/animations etc for a specific level. Is there a specific way I should go about doing this? We would need the datablock to load in before the level is started, and then unload when the level is completed. Is it possible to unload a datablock on demand? And if so will that remove everything contained in the datablock from memory? I found I can add the level specific datablock to the $managedDatablockSet sim set which loads the correct assets into memory, but from what I can tell even if I call delete on $managedDatablockSet the assets are not deleted from memory. Thanks in advance for all the help!

#1
09/11/2009 (3:53 am)
Having the same problem, I created a datablock in a function where there are variables assigned to the datablock's fields. Whenever I run the function, the datablock's fields are updated depending on my variables.

Still has some bugs when the engine runs it...
#2
09/11/2009 (9:37 am)
Do a forum search, there's a long thread about this that I a number of people collaborated on for a good solution, including myself.
#3
09/11/2009 (11:59 am)
if you do find this link please post it here.
So far I've been using similar solution. loading datablocks in functions when needed and deleting them when not needed using .delete()
It would be great to learn a better way.
#4
09/11/2009 (1:08 pm)
Check out this thread:
http://www.garagegames.com/community/forums/viewthread/86451

This is one of them most useful things I've learned from the forum, my game wouldn't of been possible without this thread.

#5
09/11/2009 (1:22 pm)
Thanks Bret,
I guess I am doing the similar thing only manually and only for the actual game, not the editor.
This seems way better. I wonder if TGB should work like that by default.