Download - Wanda Dann Don Slater Classes and Objects Copyright 2012 Wanda Dann, Don Slater All rights reserved
Wanda [email protected]
Classes and Objects
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
Alice EnvironmentScene EditorCode Editor
Classes
Objects
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
Each 3D model is a pre-written class In Alice, a class defines
◦ A plan for constructing an object in an Alice scene◦ Actions an object of that class can perform
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
An Alice class is similar to an architect's blueprint for building a house.◦ Not the actual house -- just a plan for
constructing a house, based on a sketch of what it will look like.
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
An instance of a class is an objectThe following slides illustrate how to create
(construct) an object in an Alice scene.
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
Where the program for
the animation or
game is written
Code Editor
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
Code editorScene view
Methods panel
Control tiles
Click on Setup
Scene to go to the Scene Editor
Go to Scene Editor
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
Scene Editor
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
Where the scene for the animation or
game is created
Scene setup panel
Gallery panel
Gallery foldersIn the gallery, classes are organized in folders.• Each class folder is like a drawer in a file cabinet, where all
classes of the same type are stored.
Flyer (has wings and can fly)
Biped (walks on 2 legs)
Quadraped (walks on 4 legs)
Swimmer (lives in water, swims)
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
Select the class folder for the type of object that you wish to add to the scene.
In this example, we click on Quadruped.
Select class folder
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
• Within the Quadruped folder are images of each class in this folder.
• Each image is labeled with the name of the class and shows a preview for an instance of that class.
Quadruped – walks on 4 legs
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
Click on the image to select one of 5 versions of the BabyDragon class.
Select class
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
5 different BabyDragonclasses
Click on the image to create a new BabyDragon object
Select class
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
Enter a name for the new object you are constructing from the BabyDragon class
Adding a Camel object to a Scene
• We have constructed an instance of the BabyDragon class and identified it with the name fergie.
• We say an instance of a class is an object.
Instance/object
Copyright 2012 Wanda Dann, Don SlaterAll rights reserved
• An instance of an object may be added to a scene by clicking and dragging the image into the scene view.
Instance construction - Alternative
Instances of same class• Can have more than one instance of the
same class. • Example: fergie and bert are two instances of
the BabyDragon class.