Game Development Community

Lag issue when creating a t2dImageMapDatablock in TGB

by Josias Gibbs · in Torque Game Engine · 09/06/2008 (11:38 am) · 2 replies

I have a behavior in an object (called Swarmship) that has this simple function:

function DisplayShip01SwarmshipBehavior::onAddToScene(%this, %scenegraph)
{
new t2dImageMapDatablock(iMap01Spikewing)
{
imageMode = "cell";
cellWidth = 200;
cellHeight = 150;
imageName = "game/data/images/Swarmship01_rlOFF.png";
};
new t2dImageMapDatablock(iMap02Spikewing)
{
imageMode = "cell";
cellWidth = 200;
cellHeight = 150;
imageName = "game/data/images/Swarmship02_rlON.png";
};

my issue is that this function seems to cause a noticable burst of lag whenever this object is added to the scene (ie: the game freezes for about a fourth of a second, then goes normally after that with no more lag)

This object gets added to the scene constantly (ie: ships hyper into the star system) - so this is a bit of a problem (I can't have a lag spike every time a Swarmship enters the star system). Is there any way to either:

a - run this code just once for a template object, then never run it again.
b - reduce the lag to make it unnoticable.
c - hide the lag somehow.

Any help would be highly appreciated.

(oh, and I haven't forgotten about my other posts - I'm still looking into the sample games and tutorials and whatnot, and I will get back to everyone on those)

#1
09/06/2008 (2:12 pm)
Shouldn't those imageMap's be allocated in advance in, say, datablocks.cs? You can have multiple object's reference the same imageMap, so they don't each need their own.
#2
09/07/2008 (9:19 am)
Yes... yes they should!