How to execute code at startup
Andreas Raab
Andreas.Raab at gmx.de
Wed Feb 6 16:31:03 UTC 2002
Another solution is the following:
* 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.
Cheers,
- Andreas
> -----Original Message-----
> From: squeak-dev-admin at lists.squeakfoundation.org
> [mailto:squeak-dev-admin at lists.squeakfoundation.org] On
> Behalf Of Aaron J Reichow
> Sent: Wednesday, February 06, 2002 5:17 PM
> To: squeak-dev at lists.squeakfoundation.org
> Subject: Re: How to execute code at startup
>
>
> Hi!
>
> > 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?
>
> 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
>
> Aaron Reichow :: UMD ACM Pres :: http://www.d.umn.edu/~reic0024/
> "the only difference it makes if some dust on the clay" :: atmosphere
>
>
>
More information about the Squeak-dev
mailing list
|