Procedural+Method+Built+in+Items


 * Procedural: Built-in Methods**
 * Procedural Methods
 * Change the **size** of an object
 * Change the **position** of an object in the scene
 * Change the **orientation** of an object in the scene
 * Other procedures
 * **Detail**parameter options

The Methods panel has three tabs so as to distinguish between // procedural // methods, // functional // methods, and methods related to that object's specific // properties. // This figure illustrates the three tabs in a side-by-side listing, using // penny // (an instance of ** Penguin ** ) as an example.



**Side-by-side listing of built-in procedural, functional, and property methods**

Important concepts:


 * //Procedural methods// describe actions that may be performed by an object, such as move, turn, or roll. These actions often change the location and/or orientation of an object. The important thing to know about procedural methods is that they each perform an action but do not compute and return an answer to a question.
 * //Functional methods// are expressions that compute and answer a question about an object such as what is its width or height, or what is its distance from another object.
 * //Properties methods are//methods for retrieving (get) and changing (set) specific properties of an object of this class. These specific properties, such as paint, opacity, name, and vehicle, are used in animation rendering.

As a convenient reference, the remainder of this section describes the method tiles commonly found in the Procedures, Functions, and Properties tabs for an object in a scene. The Figures and examples use the alien object, as seen in this screenshot.



**PROCEDURAL METHODS**

//Change the size of an object//
Every object in Alice has three dimensions, all having a height, width, and depth (even if the value of that dimension is 0.0; e.g., a disc may have a height of 0.0). These procedures change the size of an Alice object, by changing all the dimensions at the same time, proportionately. Procedures that change the value of height, width, or depth are shown in the figure and summarized in the following table.



**Procedures that change the size of an object**

The //set// procedures change that dimension to the absolute size provided in the statement. For example if the alien has a height of 1.5 meters, the statement

**alien.setHeight** //**height: 2.0**//

will animate the alien growing to a height of 2.0 meters. The value 2.0 is an **argument** to the method, to be used as the targeted height.

The //resize// procedures change a dimension by the factor of the argument value provided in the statement. For example if the same alien has a height of 1.5 meters, the statement **alien.resizeHeight** //**factor: 2.0**// will animate the alien growing to the height of 3.0 meters, as the height of the alien is increased by a factor of 2.

**Procedures that change the size of an object**


 * **Procedure** || **Argument(s)**  ||  **Description**  ||
 * **setWidth** || //DecimalNumber//  || Changes the value of the object's width to the value of the argument//width//, with width and depth changed proportionately. ||
 * **setHeight** || //DecimalNumber//  || Changes the value of the object's height to the value of the argument//height//, with height and depth changed proportionately. ||
 * **setDepth** || //DecimalNumber//  || Changes the value of the object's depth to the value of the argument//depth,//with height and width changed proportionately. ||
 * **resize** || //DecimalNumber//  || Changes all the dimensions of the object by the value of the argument//factor//, proportionately ||
 * **resizeWidth** || //DecimalNumber//  || Changes the width dimension of the object by the value of the argument//factor//, with height and depth changed proportionately. ||
 * **resizeHeight** || //DecimalNumber//  || Changes the height dimension of the object by the value of the argument//factor//, with width and depth changed proportionately. ||
 * **resizeDepth** || //DecimalNumber//  || Changes the depth dimension of the object by the value of the argument//factor//, with height and width changed proportionately. ||

//Change the position of an object in the scene// Every object in Alice has a specific position and orientation in the scene. Each object can move to its //left// or //right//, //forward// or //backward//, //up// or //down//. Procedures that change an object’s position are shown in the figure and summarized in the following table.



**Procedures that change the position of an object in the scene**

**Procedures that move an object to a different position in the scene**

ABOVE, BELOW, RIGHT_OF, LEFT_OF, IN_FRONT_OF, BEHIND;//Model// || Animates movement of the object, so that it ends up 1 meter from the//target//object (a 3D Model) along the specified//spatialRelation// ||
 * **Procedure** || **Argument(s)**  ||  **Description**  ||
 * **move** || //Direction, DecimalNumber//  || Animates movement of the object in the specified//direction//according to its own orientation, by the specified//amount// ||
 * **moveToward** || //Model, DecimalNumber//  || Animates movement of the object, by the specified//amount//, in the direction of the//target//object (a 3D Model) ||
 * **moveAwayFrom** || //Model, DecimalNummber//  || Animates movement of the object, by the specified//amount//, directly away from the position of the//target//object (a 3D Model) ||
 * **moveTo** || //Model//  || Animates movement of the object, in the direction of the//target//object (a 3D Model)until the pivot point of the object and the pivot point of the target are exactly the same; the original orientation of the object is unchanged. ||
 * **moveAndOrientTo** || //Model//  || Animates movement in the direction of the//target//object (a 3D Model) until the pivot point of the object and the pivot point of the target are in exactly the same position and the orientation of the object is the same as the orientation of the target object. ||
 * **place** || //spatialRelation://

//Change the orientation of an object in the scene// Every object in Alice has a specific orientation in the scene, with its own sense of //forward// and //backward//, //left//and //right//, //up// and //down//. Importantly, each object has a //pivot// or //center// point, around which these rotations occur. Procedures that change an object’s position are shown in the figure and summarized in the following table.



**Procedures that rotate an object**

Turn rotations can be LEFT, RIGHT, FORWARD, or BACKWARD. Roll rotations can only be LEFT or RIGHT. The rotations occur in **the direction of an object's own orientation, not the camera's point of view and not** **as seen by the viewer of the animation.** For example, if an object is given an instruction to turn LEFT, the object will turn to its own left (which may or may not be the same as left for the person viewing the animation).

The amount of a rotation is always described as a fractional part of a full rotation, expressed as a decimal value. For example, the statement

**alien.turn** //**direction: RIGHT, amount: 0.25**//

will animate the alien turning to its right ¼ of a full rotation, expressed as 0.25. Although a full rotation is 360 degrees and ¼ rotation is 90 degrees, Alice does not use degrees to specify the rotation amount. So, always convert any amount in degrees to a fractional part of a rotation, expressed as a decimal value.

Generally a //turn// will result in an object's sense of //forward// changing as the animation occurs, although it may come back to its original orientation if it turns all the way around. A //roll// will result in an object's sense of //up// changing as the animation occurs, although it may come back to its original orientation if it rolls all the way around. It may be helpful to note that an object's sense of forward stays the same during a roll.

**Procedural methods that rotate an object**


 * **Procedure** || **Argument(s)**  ||  **Description**  ||
 * **turn** || //Direction, DecimalNumber//  || Animates a turn of an object around its pivot point, in the specified//direction//according to its own orientation, by the specified//amount//,given in fractional parts of a rotation. The object's sense of**forward**will be changing during the animation ||
 * **roll** || //Direction, DecimalNumber//  || Animates a roll of the object around its pivot point, in the specified//direction//according to its own orientation, by the specified//amount//,given in fractional parts of a rotation. The object's sense of**forward**will remain unchanged during the animation ||
 * **turnToFace** || //Model//  || Animates a turn of the object around its pivot point, so that its sense of forward will be in the direction of the//target//(a 3D Model object) ||
 * **orientToUpright** ||  || Animates a rotation of the object around its pivot point, so that its sense of up will be perpendicular to the//ground// ||
 * **pointAt** || //Model//  || Animates a rotation of the object around its pivot point, so that its sense of forward will be in the direction of the//target’s//(a 3D Model object) pivot point ||
 * **orientTo** || //Model//  || Animates a rotation of the object around its pivot point, so that its orientation will be exactly the same as the orientation of the target (a 3D Model object). The object's position will be unchanged. ||

//Other procedures// Some procedures do not neatly fit into the descriptive categories of the preceding paragraphs. We have collected these procedures into a category called “Other.” These procedures provide program output (//say//, //think//, //playAudio//), manage timing in an animation (//delay//), simplify returning an object to its original position after an animation (//straightenOutJoints//), and allow one object to be the vehicle for another object as it moves around the scene (//setVehicle//). The Other procedures are shown in the figure and summarized in the following table.



**Other procedures**

**Other procedures**


 * **Procedure** || **Argument(s)**  ||  **Description**  ||
 * **straightenOutJoints** ||  || Restores all the joints of//this//object to their original position, when//this//object was first constructed in the scene editor ||
 * **say** || //textString//  || A speech bubble appears in the scene, containing the value of the//text//argument, representing something said by//this//object ||
 * **think** || //textString//  || A thought bubble appears in the scene, containing the value of the//text//argument, representing something thought by//this//object ||
 * **setVehicle** || //Model//  || Any movement or rotation of the//target//(a 3D Model object) will produce a corresponding movement by//this//object.//This//object cannot be a vehicle for itself, and two objects may not have a reciprocal vehicle relationship (in other words,//this//object cannot be the vehicle of the//target//object, if the//target//object is already the vehicle for//this//object) ||
 * **delay** || //DecimalNumber//  || The animation pauses for the length of the//duration//in seconds ||
 * **playAudio** || //??? (sound file)//  || The entire imported sound file (either .mp3 or .wav format) will be played in the animation. The length of sound clip that is actually played can be modified in**AudioSource**drop-down menu and selecting//**Custom Audio Source…**//See**Chapter 5: How to…** ||

**Important concepts**

//Do in order//


 * When a delay action is performed within a //Do in order//, Alice waits the specified number of seconds before proceeding to the next statement. Calling a delay on the scene will suspend the animation until the delay is complete.
 * When a //playAudio// action is performed within a //Do in order,// Alice plays the sound for the specified amount of time before proceeding to the next statement.

//**Do together**//


 * When a delay action is performed within a // Do together //, other statements within the // Do together // are not affected. However, the delay does set a minimum duration for execution of the code block within the // Do together // . For example, in the code block shown below, the alien will move and turn at the same time (duration of 1 second), but Alice will not proceed to the statement following the // Do together // until the delay is completed (2 seconds).

//** Do together **//

//** alien.turn direction: RIGHT, amount: 0.25 **//

//** alien.delay duration:2.0 **//

//** alien.move direction: FORWARD, amount: 1.00 **//

//** bunny.turn direction: LEFT, amount: 1.0 **//


 * When a // playAudio // action is performed within a //Do together//, Alice plays the sound at the same time as other statements within the // Do together // are executing (for example, as background music).

**Use**//**detail parameter**//**options** Most procedures in Alice have a set of parameters with default argument values. These are known as //detail// parameters. The detail parameters enhance or fine tune the animation action performed when a statement is executed.



The three most common detail parameters are //asSeenBy//, //duration//, and //animationStyle//. There are a few procedures that may not use all of these details, or they may have a different set of details, appropriate for that particular animation. This table summarizes the detail parameter options.

**Details**

Other animation styles: //BEGIN_GENTLY_AND_END_ABRUPTLY//begins with a//gradual//acceleration to top speed and ends with a sudden stop. //BEGIN_ABRUPTLY_AND_END_GENTLY//starts at top speed and ends with gradual deceleration. //BEGIN_AND_END_ABRUPTLY//starts at top speed and ends with a sudden stop. ||
 * **Detail** || **Values**  || **Description** ||
 * **asSeenBy** || //Model//  || The movement or rotational animation of this object will be as if//this//object had the pivot point position and orientation of the//target//object ||
 * **duration** || //DecimalNumber//  || By default, Alice animation methods execute in 1 second. This modifier changes the duration value to a specified length of time. ||
 * **animationStyle** || //BEGIN_AND_END_ABRUPTLY BEGIN_GENTLY_AND_END_ABRUPTLY BEGIN_ABRUPTLY_AND_END_GENTLY BEGIN_AND_END_GENTLY//  || The default animation style is//BEGIN_AND_END_GENTLY,//which begins with areasonable period of acceleration, then constant movement at some top speed, followed by a reasonable period of deceleration.