sprites, types, and loading?

BlitzMax Forums/MiniB3D Module/sprites, types, and loading?

Pragun(Posted 2007) [#1]
hi. i'm making particles w/mini b3d. i have a "type" called particle, and the particle has a sprite field. it is loaded like this:

Field sprite=LoadSprite("fire.png")

The problem with this is that everytime I generate a new particle (Local p:particle=new particle), I believe that the type re-loads fire.png from the harddrive. Thus with around 50 particles, I am experiencing significant slowdown.

Anyone have tips or know a way around loading this way?
Thanks!


Who was John Galt?(Posted 2007) [#2]
Try
global sprite=LoadSprite("fire.png")
in your type. I think it will work but don't have Blitz here to be sure.


(tu) sinu(Posted 2007) [#3]
Everytime you create a new type you are loading the image from the harddrive.
Just have a global in your type which loads the image, then do a

field sprite = copyimage(Global_sprite)


tonyg(Posted 2007) [#4]
.
Redundant post


tonyg(Posted 2007) [#5]
.


Pragun(Posted 2007) [#6]
thanks guys. and could anyone tell me what the commands are for doing the same w/a mesh and texture?


Pragun(Posted 2007) [#7]
oh duh its probably copymesh...but also i just checked. copyimage doesn't exist?


bradford6(Posted 2007) [#8]
global particle_tex = loadtexture("blah.jpg")

Sprite = createsprite()
entitytexture sprite , particle_tex

this way, you only load the texture once.


Pragun(Posted 2007) [#9]
thanks...i'm having a huge memory leak though. to free the memory...do i just do FreeEntity sprite ? or sprite = null ? GC looks like it hasn't been cleaning something up lately. I can post code later if need be.