Creating and Calling Procedures Alice 3 Beta. A few choices to be made Right window, upper left hand...
-
Upload
helen-west -
Category
Documents
-
view
213 -
download
1
Transcript of Creating and Calling Procedures Alice 3 Beta. A few choices to be made Right window, upper left hand...
Creating and Calling ProceduresAlice 3 Beta
A few choices to be madeRight window, upper left hand corner start by
clicking on Class “MyScene” button
1.Click “class”
2 Click MyScene
3 Click Procedures 4 Click
Declare Procedure
After requesting to create a procedure, Name it (any legal name)
New Tab appears named with your new method name
This example will use a parameter to be passed into method when the method is called
Click on Add Parameter button
Next click on Value Type arrow
This example will use an integer
Many other types are available
This example “howHigh” keyed in as name of integer parameter
Any legal name OK , name should relate to purpose of parameter
Continue by clicking “OK” button
New Button “howHigh” appears and “Add Parameter” button may be used to create other
parameters as needed
“howHigh”Add Parameter
Many tiles can be dragged to the right in this example a Princess “move” was chosen
This example chose “UP”
Princess “Move”
A number (an integer) place holder is picked 1.0 in this example
Result of last 1 integer choice (1.0 is really just 1 an integer)
Example Princess will move up 1 meter
Integer “howHigh” button dragged toward the 1.0 placeholder
Target for howHigh parameter
“howHigh” dropped off on top of 1.0 replacing it
Click on “run X” tabThen click on This a.k.a. Scene
Find the method you want to call “princessMethod” in this example drag the tile to the right window
Choose an integer “meters Princess will move UP” in this example “3” chosen as demonstration
Result tile on right below an existing instruction. Call to princessMethod passing 3 “howHigh”
parameter
Next run program
Result: Princess moves UP too far
Call adjusted to “2” meters UPre-run program
Princess now completely in frame
Example has worked Method called correctly, adjusted when necessary
• The method may be called many times and passed the same parameter (argument) or a different one each call.