PDA

View Full Version : LoadSprite


matteo.m
11-26-2006, 05:55 PM
Hi , i have a question: how i can load sprites not from disk but from a package where i stored a bunch of them?

thanks

PointOfLight
11-26-2006, 05:59 PM
Unfortunately you can't directly. You have to use ExtractFileFromPackage, which writes the file to a temporary location, then read that file in, then delete the file. A good time for this would be loading screens between levels.

This does bring up a couple of points, though. What is the path used to store the temporary file? Also, it would be great if there was a way to read from a package file directly into memory.

matteo.m
11-26-2006, 06:04 PM
Yes i agree with you Eric... now that i have a bunch of sprites,a wav, a Font file :D , a protracker mod file, i'm packaging to a one single file, but i have to manage how to extract and load everything. Should be really nice to have this done directly or... to know at least a temporary place to clean everything after the use ;) , thank you again

PointOfLight
11-26-2006, 06:12 PM
Actually, the function does return the temporary file name, so you can clean up after yourself, so to speak. I'm just saying that I'd like the option to specify the directory that all of the temp files get written to.

zehlein
11-26-2006, 06:34 PM
LoadPackageFile() won't do the job? As I glanced over it I thought it would do exactly what you need.

PointOfLight
11-26-2006, 07:45 PM
Yes, that will load it into memory (can't believe I missed that function). However, I don't think you could use that information as an image or wave file, for example. There would need to be a special function that you could tell what type of data you were loading and it would automatically convert it for you. There might be ways to do that with the data that LoadPackageFile returns, but it would probably be tedious.

zehlein
11-26-2006, 08:06 PM
Well, at least it could be worth a try to pass the data$=LoadPackageFile() to a sprite's surface via DrawSurface. As long as the format is bitmap of course.

matteo.m
11-26-2006, 08:06 PM
That is exactly why i started this thread! I've been trying loadpackagefile and then i realized that after loaded , i had no way to use it as parameter for the sprite function or for sound function. So by the way i'm using the extraction in the temporary folder and then i clean the files after loaded. Thanks a lot

kornalius
11-27-2006, 12:43 AM
Other than using ExtractFileFromPackage() there are no way.

I don't have any plans on changing this in the very near future but in a more distant future I can add functions to load a sprite, music and sound from memory.

kornalius
11-27-2006, 06:58 PM
The LoadPackageFile() function now returns a memory handle and doesn't create a temporary file anymore.

You can use this function with the two nice new functions we have just implemented:

LoadSpriteFromMem()
LoadSoundFromMem()

You can load sprites and music/sound directly from a memory buffer now.

I hope you guys will like it.

PointOfLight
11-27-2006, 07:08 PM
You guys are definitely awesome.

zehlein
11-27-2006, 08:04 PM
Hey, pretty sure we like it! Great!

matteo.m
11-27-2006, 09:31 PM
;) I noticed! Greath work guys

matteo.m
11-27-2006, 09:34 PM
By the way Kornalius, now I need the 1.1 before the contest submission :)

kornalius
11-28-2006, 03:05 PM
I give myself another week or two to finish it, so you will at least get one week to finish your app before the deadline.