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?
Rudi Angela
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
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@lists.squeakfoundation.org [mailto:squeak-dev-admin@lists.squeakfoundation.org] On Behalf Of Aaron J Reichow Sent: Wednesday, February 06, 2002 5:17 PM To: squeak-dev@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
squeak-dev@lists.squeakfoundation.org