Question about ETOYS and Morphs
lex at cc.gatech.edu
Tue Apr 9 13:47:44 UTC 2002
"Michael Garrett" <garrett.technologies at worldnet.att.net> wrote:
> I just downloaded Sqeak and in 3 days programmed an interactive game with my
> 6 year old!! The whole Squeak environment is amazing......I am addicted...
> Once I create some SketchMorphs using the sketch editor, how can create a
> subclass that includes the
> image so that I can instantiate the SketchMorph ( and its form )and interact
> with it directly from smalltalk code??
> I hope my terminology is understandable..
There are a few approaches.
If you stick purely with EToys, then don't bother! Put the image in a
flap somewhere, and then make copies of it as you desire.
If you stick within one image, a good approach is to store the image in
a class variable. To do this:
1. add a class variable somewhere, named say FroofySketchMorph
2. From an inspector on the SketchMorph, do "X := self" and say "create
global variable" when asked about X.
3. From a browser on the class, say "FroofySketchMorph := X. X :=
To literally do what you ask for, I thought you could do "make own
subclass" from the gray handle, followed by someo ther operation to set
a morph as a default instance. But I don't see a way to do this second
operation, now that I look. Anyway, "make own subclass" is one of the
little niceties in Squeak that no one seems to know about.
Finally, if you want to be able to file-out your image as Smalltalk
code, you can inspect the form and do "self storeString" on the
SketchMorph's Form to get a string that will evaluate to the form. Then
you can do "SketchMorph withForm: theForm" to recreate the SketchMorph.
You can see this kind of thing in Cursor's class methods. You might
still want to stick the result in a class variable, to avoid recreating
the form all the time.
More information about the Squeak-dev