creating and calling procedures alice 3 beta

22
Creating and Calling Procedures Alice 3 Beta

Upload: orea

Post on 06-Feb-2016

34 views

Category:

Documents


0 download

DESCRIPTION

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. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Creating and Calling Procedures Alice 3  Beta

Creating and Calling ProceduresAlice 3 Beta

Page 2: Creating and Calling Procedures Alice 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

Page 3: Creating and Calling Procedures Alice 3  Beta

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

Page 4: Creating and Calling Procedures Alice 3  Beta

New Tab appears named with your new method name

Page 5: Creating and Calling Procedures Alice 3  Beta

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

This example will use an integer

Many other types are available

Page 7: Creating and Calling Procedures Alice 3  Beta

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

Continue by clicking “OK” button

Page 9: Creating and Calling Procedures Alice 3  Beta

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

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 number (an integer) place holder is picked 1.0 in this example

Page 12: Creating and Calling Procedures Alice 3  Beta

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

Integer “howHigh” button dragged toward the 1.0 placeholder

Target for howHigh parameter

Page 14: Creating and Calling Procedures Alice 3  Beta

“howHigh” dropped off on top of 1.0 replacing it

Page 15: Creating and Calling Procedures Alice 3  Beta

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

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

Page 17: Creating and Calling Procedures Alice 3  Beta

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

parameter

Page 18: Creating and Calling Procedures Alice 3  Beta

Next run program

Page 19: Creating and Calling Procedures Alice 3  Beta

Result: Princess moves UP too far

Page 20: Creating and Calling Procedures Alice 3  Beta

Call adjusted to “2” meters UPre-run program

Page 21: Creating and Calling Procedures Alice 3  Beta

Princess now completely in frame

Page 22: Creating and Calling Procedures Alice 3  Beta

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.