230 likes | 348 Views
Creating and Calling Procedures Alice 3 Beta. A few choices to be made Right 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.
E N D
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)
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
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
Click on “run X” tab Then 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
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.