Walking the Walk with Lingo

1. Create a new movie called lingoWalker.1014. Go to the Tempo Channel in frame 1 and set the tempo to 5 frames per second.

2. Open the Movie Script for this movie. Enter the following:

on startMovie
  global step
  step = 0
end startMovie

3. Import the following graphics from the usual place:

  • lingoWalkerR1.png
  • lingoWalkerR2.png
  • lingoWalkerL1.png
  • lingoWalkerL2.png

4. Following the order above, create a sprite for each image in channels 1 through 4. So lingoWalker R1 is in channel 1, lingoWalker R2 in channel 2, and so forth. When you have created each sprite, use the Property Inspector to set the length of the sprite to 2 frames.

5. Using the button tool, create a button. Give it the name "rightBtn" in your cast. Place a sprite of this button in channel 5. Give it the label "Right" on the stage and position it in the upper right corner. Extend the sprite to 2 frames.

6. Create a button with the name "leftBtn." Place a sprite of this button in channel 6. Give it the label "Left" on the stage and position it to the left of "rightBtn". Extend the sprite to 2 frames.

7. Write a Behavior Script on frame 1. Use the exitFrame handler that comes up by default. In this script, make sprite 1 visible and sprites 2, 3, and 4 invisible. Leave sprites 5 and 6 alone.

8. Write a Behavior Script on frame 2. Use the default exitFrame handler. The script consists of one line: "go to the frame".

9. Click on the button named "rightBtn" in your cast. Open its Cast Member Script and enter the following:

on mouseDown
  global goRight
  goRight = true
end mouseDown

on mouseUp
  global goRight
  goRight = false
end mouseUp

10. Write similar handlers in the Cast Member Script for "leftBtn," substituting the global variable goLeft for goRight.

11. Re-open the Behavior Script for frame 2 (NOT frame 1!). Add an enterFrame handler. Within that handler type the following script:

  global goRight, goLeft, step
  
  step = step + 1

  -- MOVE RIGHT 
  if goRight = true then
    
    sprite(3).visible = false
    sprite(4).visible = false
    
    if step = 1 then
      sprite(1).visible = true
      sprite(2).visible = false
    else
      sprite(1).visible = false
      sprite(2).visible = true 
    end if
    
    sprite(1).locH = sprite(1).locH + 5
    sprite(2).locH = sprite(1).locH
    sprite(3).locH = sprite(1).locH
    sprite(4).locH = sprite(1).locH
    
  end if
  -- END MOVE RIGHT
  
  -- more to come here
  
  if step = 2 then step = 0

12. Look carefully at the lines between the comment "-- MOVE RIGHT" and the comment "-- END MOVE RIGHT". Figure out how to modify these lines to handle leftward character movement. You will need to make many small changes, but the framework of the script will be identical. Where you see the comment "-- more to come here", place the code that controls leftward movement.


University of Baltimore Logo

Copyright © 2003 School of Information Arts and Technologies