Working with the Repel From Behavior


The last Simulations behavior that you'll experiment with in this lesson is the Repel From behavior. Simulations behaviors include Attract and Repel behaviors that either move objects toward each other or cause them to move away from each other. The Repel From behavior is applied to an object or objects; then you specify what the objects are repelled from.

Let's open the project 4-7 Repel From to see this Simulations behavior in action.

1.

Choose File > Open and select 4-7 Repel From in the Lesson_04 folder.

2.

Play the project in the Canvas to see the effect.

As the AquaBall bounces around the frame, the small white circles move away from the AquaBall.

NOTE

This project was really easy to create. The AquaBall is just an object with Throw and Edge Collision behaviors. The small circles are actually bullet points (Option-8) that I created as one piece of text using the Text tool.

Now it's your turn.

Resetting Parameters in the Inspector

The secret to making the Repel From behavior work is experimenting with the parameters until you get the desired result. Let's re-create the effect we just saw by setting the Repel From parameters from scratch.

First, let's reset the current parameters in the Inspector. To reset parameters, you click the Reset button (X) in the Inspector.

To open the Inspector from the Dashboard, Motion gives you a really handy shortcut. All you need to do is click the Inspector button, which looks like a white circle with an i in the center.

1.

In the upper-right corner of the Dashboard, click the Inspector button.

The Inspector tab opens in the Utility window with the Behaviors tab showing.

2.

Click the Reset button.

The parameters are reset to the default values.

3.

Play the project in the Canvas.

The AquaBall bounces around behind the white circles.

Setting Repel From Parameters in the Inspector

To make the Repel From behavior work, you need to designate the object that you want other objects to be repelled from.

All you need to do to designate an object is to drag the object from the Layers tab to the Object well. The Object well is the empty square next to the Object parameter.

1.

Press Cmd-4 to open the Layers tab.

2.

Drag the AquaBall object from the Layers tab to the Object well in the Inspector.

The AquaBall appears inside the Object well.

3.

Watch the project in the Canvas with the default Repel From settings.

The default settings don't make the white circles repel enough to be effective. You need to increase the strength of the repellency.

4.

In the Inspector, drag the Strength slider for the Repel From parameters all the way to the right to change the Strength value to 100.

5.

Watch the project in the Canvas again.

The effect is better, but the repellency still isn't strong enough. So what do you do when you've reached the maximum value on the slider and still need more strength? Easyjust type in the value you want.

6.

Click the Strength value field and type 800; then press Return.

There you have it. You've re-created the Repel From behavior settings.

NOTE

Parameter values in the Dashboard are fixed, so if you want to exceed the initial parameter values, you need to type a new value in the parameter field in the Inspector.

7.

Experiment with the different Repel From parameters to create your own repellency effect.

8.

When you've finished, save your project in the My Projects folder.



    Apple Pro Training Series Getting Started with Motion
    Apple Pro Training Series: Getting Started With Motion
    ISBN: 0321305337
    EAN: 2147483647
    Year: 2005
    Pages: 283
    Authors: Mary Plummer

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net