Classes in eToys

Scott Wallace scott.wallace at squeakland.org
Wed Dec 22 11:27:04 UTC 2004


Hi, Blake,

Actually, each object you script is already a member of a genuine 
custom class, whose instance variables are precisely the "variables" 
defined in the object's Viewer, and whose methods are precisely the 
"scripts" you have built for the object, and of which there can be 
any number of instances present, which share the same code and the 
same instance structure.

You can see this class in a traditional Smalltalk browser, and you 
can add your own code to the class if you care.  Or modify the code 
generated by the tile scripts.

(To find the class, follow the "more..." branch of a Viewer's main 
menu.  Or open an Inspector on the morph, and then evaluate "self 
player" in the bottom pane of the Inspector, and this will get you 
right to the actual class.)

You can make many *instances* of this class, and they will all share 
the same instance structure and the same scripts, and if you modify 
any script, the modification instantly applies to all of the 
instances.  Also, in the "scripting" category of the Viewer, you'll 
see a number of commands that allow you to send messages to all of 
the siblings.

(There are a number of ways to create sibling instances, both 
programmatically (the "copy" tile phrase) and by direct manipulation 
-- the olive halo handle, if you see one; or follow "siblings..." 
menu branch in a morph's halo menu.)

Such classes (called Uniclasses) are subclasses of a prototypical 
base user-object class (called a Player) that is hooked up to the 
graphical world of morphs (every player has a costume, which is a 
palpable morph that you touch.)  Thus, your player starts out life 
with a fairly rich vocabulary, of which only the end-user-level is 
visible in the default Viewer.

Cheers,

  -- Scott

PS:  Squeakland 3.8 or Squeak 3.8gamma are the best systems for 
exploring use of multiple instances, since they contain several 
useful fixes to problems in 3.7.


At 1:33 AM -0800 12/22/04, Blake wrote:
>Is there any way to go from the prototype you build as an eToy to a 
>genuine class?




More information about the Squeak-dev mailing list