| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Alice Tutorial - Creating Methods

Page history last edited by Steve Sweeney 14 years, 2 months ago

By creating our own methods, we can organize our Alice worlds, making them easier to understand and maintain.  Another advantage of adding methods is to reduce a set of complex actions into a single command.  If this action is required multiple times throughout the scene, it is much easier to add a single command, rather than copying and pasting a long list of commands.

 

  1. Start Alice and create a new world.
  2. Select the grass template.
  3. Add an instance of the frog class from the Animals gallery.

  4. Click on the frog object.  Notice that there are already some custom methods included with this object.

  5. We are going to create a new method for the frog called "jump", which will cause the frog to leap 1 metre into the air and then drop back to the ground.

    1. Select the frog object.

    2. Under the Methods tab, click on the create new method button.

    3. Type "jump" and hit enter to name the method.  The window to edit this method should automatically open.

    4. Add the following methods to the jump method:

      1. frog moves up 1 metre

      2. frog moves down 1 metre
    5. Select the "world.my first method" tab.
    6. Add the new method to the world.
    7. Run the world.
  6. Save your world in the appropriate folder.  Call the world "FrogJumpWorld.a2w".

    Extending

     

  7. The movement of the frog up and down doesn't seem very realistic.  Modify your method to improve the appearance (hint: consider the style property in the move method).
  8. When it jumps, the frog's legs should probably extend (to make it jump), and then return to a seated position when it lands.  You might want to explore capture pose under properties and set pose under methods.
  9. Create a second new method called jumpSpin where the frog leaps into the air and does one complete rotation before it hits the ground.
    1. Coordinate the timing of the spin with the timing of the jump, so they start and end at the same time.

 

Comments (0)

You don't have permission to comment on this page.