> I'm trying to use Squeak for creating a game that is supposed to
> automatically start when the user opens the image. How do I get Squeak
> to start running my startup code as soon as the image is opened?
* Open the World menu.
* Click on the "do..." item
* Choose "edit this list"
* Add a line saying:
Smalltalk saveSession. MyGameMorph openInWorld.
[Note this _needs_ to be a single line, so it might be easier to have a
method on the class side of your game called "saveAndStartup" which
you'd enter here].
* Accept the changes
* Click on the entry on the "do" menu.
Now your game comes up nicely. The reason why I (at times ;-) prefer
that approach is that by simply saving the image _without_ using the
above menu entry you get it back to the state where your game is not
starting up.
-----------
It's easy-
First, add a #shutDown method on the class-side of your class.
and then execute "Smalltalk addToStartUpList: YourClass."
There's also a #addToShutDownList: if you need a method called when the
image is shutting down. Just throw on a #shutDown method on the class
side.
Also of interest may be SystemDictionary>>#addToShutDownList:after:
and SystemDictionary>>#addToStartUpList:after: which do the same thing,
but allow you to have some order in which they occur.
Regards,
Aaron