Creating and Calling Procedures Alice 3 Beta. A few choices to be made Right window, upper left hand...

22
Creating and Calling Procedures Alice 3 Beta

Transcript of Creating and Calling Procedures Alice 3 Beta. A few choices to be made Right window, upper left hand...

Page 1: 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.

Creating and Calling ProceduresAlice 3 Beta

Page 2: 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.

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

Page 3: 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.

After requesting to create a procedure, Name it (any legal name)

Page 4: 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.

New Tab appears named with your new method name

Page 5: 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.

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

Page 6: 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.

This example will use an integer

Many other types are available

Page 7: 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.

This example “howHigh” keyed in as name of integer parameter

Any legal name OK , name should relate to purpose of parameter

Page 8: 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.

Continue by clicking “OK” button

Page 9: 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.

New Button “howHigh” appears and “Add Parameter” button may be used to create other

parameters as needed

“howHigh”Add Parameter

Page 10: 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.

Many tiles can be dragged to the right in this example a Princess “move” was chosen

This example chose “UP”

Princess “Move”

Page 11: 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.

A number (an integer) place holder is picked 1.0 in this example

Page 12: 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.

Result of last 1 integer choice (1.0 is really just 1 an integer)

Example Princess will move up 1 meter

Page 13: 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.

Integer “howHigh” button dragged toward the 1.0 placeholder

Target for howHigh parameter

Page 14: 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.

“howHigh” dropped off on top of 1.0 replacing it

Page 15: 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.

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

Page 16: 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.

Choose an integer “meters Princess will move UP” in this example “3” chosen as demonstration

Page 17: 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.

Result tile on right below an existing instruction. Call to princessMethod passing 3 “howHigh”

parameter

Page 18: 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.

Next run program

Page 19: 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.

Result: Princess moves UP too far

Page 20: 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.

Call adjusted to “2” meters UPre-run program

Page 21: 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.

Princess now completely in frame

Page 22: 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.

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.