Archive creation for newbies

stéphane ducasse ducasse at
Fri Nov 18 17:50:48 UTC 2005

Hi eric

have a look at the MenuIcons
because the icons are stored as methods.

importIconNamed: aString
     "self importIconNamed: 'Icons16:appearanceIcon'"

     | writer image stream |
     writer := GIFReadWriter on: (FileStream fileNamed: aString,  
     [ image := writer nextImage]
         ensure: [writer close].
     stream := ReadWriteStream on: (String new).
     stream nextPutAll: aString ; cr.
     stream nextPutAll: (self methodStart: aString).
     image storeOn: stream.
     stream nextPutAll: self methodEnd.
     MenuIcons class compile: stream contents classified: 'accessing  
- icons' notifying: nil.
     ^ stream contents

On 18 nov. 05, at 17:32, Eric Scharff wrote:

> I am developing a simple game that is extremely
> resource-intensive.  It is made from dozens of sprites,
> background images, and music clips stored as PNGs, JPEGs, and
> MIDs respectively.  I'm looking for advice about designing and
> packaging this in Squeak.
> My current idea is to have a GameResource class, which is
> basically a dictionary from which I can get the files I need.
> For example, I might call
>  levelBackground := GameResource formNamed: 'level1'.
>  levelMusic := GameResource songNamed: 'level1'.
> GameResource would cache resources internally, and load them on
> demand
> formNamed: name
>     ^GameForms at: name ifAbsent: [
>         GameForms at: name put: (Form fromFileNamed: name , '.jpg').
>         ^GameForms at: name]
> Does this make sense?
> This would be great for local file access, but I'd really
> instead like to bundle my change as something easily filed in.
> What I guess I'd really like is to manage my code with
> Monticello, and then bundle the images.
> The best answer appears to be to use a SAR file and
> SARInstaller.  The SAR file would include the MCZ and the
> resources.  How would I then write a preamble and postscript
> that would populate the GameResource dictionaries?
> This seems to be the cleanest way, but is there a better way to
> do this?  I've considered using the project loading mechanism,
> but have run into other problems (see the subsequent message).
> Are there any good examples out there on how to do this
> properly?
> Thanks,
> -Eric
> __________________________________
> Yahoo! FareChase: Search multiple travel sites in one click.

More information about the Squeak-dev mailing list