• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Lesson 9. Built-In Behaviors > Modifying Behaviors

Modifying Behaviors

The Behavior Inspector is useful for creating, modifying, and inspecting behaviors. In this task, you will use it in all three ways: to view the current behaviors, to add a behavior to the second eyeball, and to modify the properties of the second eyeball's behavior.

In the Score window, make sure the sprite toolbar is displayed. Choose View > Sprite Toolbar to make it visible if it is not.

The sprite toolbar includes a button for invoking the Behavior Inspector as well as a drop-down menu that shows a list of behaviors for a selected sprite.

Figure .

Click each of the sprites in turn, including the sprite in the behavior channel.

For the sprites that have behaviors attached, each behavior's cast number and name are shown in the behavior list.

Select the sprite in the behavior channel and click the Behavior Inspector button.

The Behavior Inspector appears, looking much as it did when you created the Hold behavior earlier.

Figure .

Click the Script button in the Behavior Inspector.

A Script window is displayed containing the Lingo code for the behavior. In this case, the code is only a few lines long and contains the go to the frame line that you have seen before. For other behaviors, hundreds of lines of Lingo script may appear here.

Figure .

Close the Script window and the Behavior Inspector. Then select the eyeball sprite that does not have an attached behavior. Open the Behavior Inspector again.

No behavior is displayed because no behavior is attached to the selected sprite.

Click the Behavior pop-up button and select Turn Towards Mouse.

Figure .

Click OK to close the Parameters dialog box.

You've now attached a behavior to the second eyeball.

Close the Behavior Inspector and play the movie. Is it what you expected?

The eyeball with the new behavior attached still does not follow the cursor. But try holding down the mouse button while you move the mouse. The eyeball follows. Release the mouse button, and the eyeball returns to its original position.

Although the second eyeball does have the Turn Towards Mouse behavior attached, its parameters are different than those of the other eyeball. Remember that you set the Always and Remain in the New Position parameters when you used the Library Palette to attach the behavior to the first eyeball.

A behavior parameter applies only to the sprite or frame to which it is attached. You can apply a different set of parameters to the same behavior attached to a different sprite.

With the eyeball sprite still selected, display the Behavior Inspector again. Click the Parameters button, next to the Script button.

Figure .

The Parameters dialog box appears and shows the current parameters for the behavior as applied to this particular sprite. They indicate how the eyeball will behave.

Figure .

Use the pop-up menus in the dialog box to set the parameters to Towards the Mouse, Always, and Remain in the New Position. Click OK.

Figure .

Save your work and play the movie.

The two eyeballs now behave identically. They follow the cursor wherever it is moved on the screen, whether or not the mouse button is pressed.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint