rotate-to-mouse.js 358 B

1234567891011121314151617
  1. var stage = new mtm.Stage('c'),
  2. arrow = new Arrow(stage.width/2, stage.height/2);
  3. stage.shapes.push(arrow);
  4. stage.play();
  5. stage.canvas.addEventListener('mousemove', function (e) {
  6. var mx = e.offsetX || e.clientX,
  7. my = e.offsetY || e.clientY,
  8. dx = mx - arrow.x,
  9. dy = my - arrow.y;
  10. arrow.radians = Math.atan2(dy, dx);
  11. }, false);