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

Lesson 23. Keyboard Control > Creating a Bounding Rectangle

Creating a Bounding Rectangle

Currently, you can use the arrow keys to move the dot entirely off the screen. However, the dot should be limited to the red boundaries of the sketch graphic. In Lesson 21, you kept a sprite from moving off the stage by making sure it didn't go beyond a vertical location by using an if-then structure and the the locV sprite property. Here you will use a different technique, creating an invisible rectangle around the area within which the dot is constrained.

1.
Open the tool palette and select the Unfilled Rectangle tool.

2.
Click the dotted line near the bottom of the tool palette.

This setting controls the border width of the rectangle; in this case, the rectangle's border will be invisible.


Figure .


3.
Draw a rectangle inside the red borders of the background graphic.

This new sprite should be in channel 3, frames 1 through 10 (if Director added the dot's sprite over more frames of the score, drag the sprite's end frame back to frame 10). In the next task, you will modify the keyDown handler to make the rectangle act as a constraining fence beyond which the dot will not be able to travel.


Figure .


4.
Save your work.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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