Skip to content

Latest commit

 

History

History
37 lines (26 loc) · 1008 Bytes

9-flowers-challenge_part2.md

File metadata and controls

37 lines (26 loc) · 1008 Bytes

Part 2

bee

In part 2, your challenge is to draw a bee that moves whenever you click on a flower.

  1. The first step is to draw a bee.

  2. The second step is to add all the parts of the bee to one bee group, for example:

var beeGroup = drawing.group();

// the bee's body
drawing
  .ellipse(200, 30)
  .fill('yellow')
  .addTo(beeGroup);
  1. To make something happen when you click a flower, you have to add a "click event listener". For example, to add a "click event listener" to a rectangle:
var moveBee = function(mouseEvent) {
  // this will print the coordinates of the mouse
  // to the console
  console.log(mouseEvent.x, mouseEvent.y);
}

drawing
  .rect(100, 200)
  .on('click', moveBee);

Now open up the inspector to the console and try clicking on the rectangle. You should see two numbers print out.

  1. You have to figure out how to make the moveBee function actually move your bee to the right place.