Restored from previous forum. Originally posted by Tomio.
I want to load a great number of sprites (20 - 40).
Small in size, so there is no problem with memory.
Only a few will be displayed at the same time.
But to save time I need to load the sprites prior.
All the sprites have the same dimension.
Is there a way to have all the sprites packed together in one datafile, load this and install/extract/expand the sprites instead of doing 20-40 LoadSprite commands?
Thank you for help../Tomio
load many sprites
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
Hi,
i think a combo with the packer library and the CatchSprite() command should do the trick, check out those and if you're still uncertain after reading about them and looking at the examples that go with the packer Lib, well just say so and we'll try to help further.
Hi,
i think a combo with the packer library and the CatchSprite() command should do the trick, check out those and if you're still uncertain after reading about them and looking at the examples that go with the packer Lib, well just say so and we'll try to help further.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Tomio.
Hello Pupil,
I was thinking about packing sprites into one file but couldn't combine things together. With your hint I think the way could be like this:
;Create the packed sprites (in a separate program):
CreatePack("PackedSprites")
Loop through list of BMP sprite files 1..20:
AddPackFile
EndLoop
ClosePack
;load the sprites 1...20:
OpenPack("PackedSprites")
Loop through the content 1...20:
Mem=NextPackFile ;but where do data go? Mem?
CatchSprite(i,Mem) ;??? OK?
EndLoop
ClosePack
Hmm, seems too simple. What do you mean?
../tomio
tomio
Hello Pupil,
I was thinking about packing sprites into one file but couldn't combine things together. With your hint I think the way could be like this:
;Create the packed sprites (in a separate program):
CreatePack("PackedSprites")
Loop through list of BMP sprite files 1..20:
AddPackFile
EndLoop
ClosePack
;load the sprites 1...20:
OpenPack("PackedSprites")
Loop through the content 1...20:
Mem=NextPackFile ;but where do data go? Mem?
CatchSprite(i,Mem) ;??? OK?
EndLoop
ClosePack
Hmm, seems too simple. What do you mean?
../tomio
tomio
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
Oh, one small hint -use 'if CreatePack(...' and 'if OpenPack(..' so you don't try to perform action on a non-opened file.
Just one more hint, i think you have to open a screen before you can load sprites(or catch sprites).
Good luck.
It is simple, your pseudo code was completely right.. If you do it like that you'll get it to work, give it a try! If you run into trouble i'll try to post a working example..Originally posted by Tomio
Hmm, seems too simple. What do you mean?
Oh, one small hint -use 'if CreatePack(...' and 'if OpenPack(..' so you don't try to perform action on a non-opened file.
Just one more hint, i think you have to open a screen before you can load sprites(or catch sprites).
Good luck.
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Tomio.
Well,
I've programmed the pseudo code of my forgoing email and, yes, it works. Once again I'm impressed how easy it is to program rather complicated processes with a few lines in PB.
I found that "Mem=NextPackFile()" gives Mem=0 at the end of the file. So you can use this to read in all sprites without knowing the number in advance.
Merendo, the idea with the big image would make thinks even more simple. But one point: I want to replace some of the sprites from time to time. Than it's more comfortable to use CreatePack.
Again thanks for help.../tomio
tomio
Well,
I've programmed the pseudo code of my forgoing email and, yes, it works. Once again I'm impressed how easy it is to program rather complicated processes with a few lines in PB.
I found that "Mem=NextPackFile()" gives Mem=0 at the end of the file. So you can use this to read in all sprites without knowing the number in advance.
Merendo, the idea with the big image would make thinks even more simple. But one point: I want to replace some of the sprites from time to time. Than it's more comfortable to use CreatePack.
Again thanks for help.../tomio
tomio