Game Development Community

Creating a t2dParticleEffect is really slow

by Damir Slogar · in iTorque 2D · 04/01/2009 (6:55 am) · 6 replies


I'm trying to create a pool of the same t2dParticleEffects when I load my level and find that it's really slow ( about 6 seconds for 90 effects). I think its reading from the eff file each time even though its the same effect file. I tried using clone and copy methods, which in theory would be faster, but these are even slower. All the examples that use t2dParticleEffect in TDN create a new instance as needed, but if its a complicated effect, wouldnt this cause the game to stutter every time you played an effect?

#1
04/01/2009 (7:05 am)
Depends on what your effect does.
you have a few hundred particles at best before the framerate is in total unplayability.
#2
04/01/2009 (10:05 am)
My problem isin't the number of particles or the framerate, it's the time it takes for the creation of the t2dParticleEffect object (loading from .eff file), and if there is a faster way to do this.
#3
04/01/2009 (3:29 pm)
My rain effects work just fine. Try reducing the amount of particles you have onscreen per frame
#4
04/02/2009 (12:15 pm)
/facepalm
#5
04/02/2009 (3:52 pm)
The load effect function will load the file each time, from the Resource Manager which it seems was designed to protect against this sort of thing. If the file has not been loaded before it'll load from the file and save it in the resource manager, otherwise, it will use the already loaded file. If the file can't be found in the resource manager, it'll load from the file again.

So by the sound of it, you are loading the file each time so it's probably not in your resource manager.
The only reason I can think why that would happen is if you are looking in a directory that hasn't been added as a resource path.
I think TGB will do that automatically for the paths it knows about, but try calling addResPath(%dir) on the directory where the effect files are, in case it hasn't.

Also, try reducing the amount of particles you have on-screen :p
#6
04/03/2009 (6:41 am)
Thanks Mat i'll try that out