Browse Source

Double click to delete towers

master
Chris Smith 12 years ago
parent
commit
089f952c45
1 changed files with 5 additions and 1 deletions
  1. 5
    1
      index.html

+ 5
- 1
index.html View File

55
        .css('position', 'absolute')
55
        .css('position', 'absolute')
56
        .offset(adjustMapOffset(tower.position, thisLevel))
56
        .offset(adjustMapOffset(tower.position, thisLevel))
57
        .rotate(tower.rotation)
57
        .rotate(tower.rotation)
58
+       .dblclick(function() {
59
+        layout.towers = $.grep(layout.towers, function(value) { return value != tower; });
60
+        $(this).remove();
61
+       })
58
        .mousedown(function(e) {
62
        .mousedown(function(e) {
59
         if (!e.shiftKey) {
63
         if (!e.shiftKey) {
60
          return;
64
          return;
71
           var newMouseAngle = Math.atan2(mouseY, mouseX);
75
           var newMouseAngle = Math.atan2(mouseY, mouseX);
72
           var mouseDelta = newMouseAngle - initialMouseAngle;
76
           var mouseDelta = newMouseAngle - initialMouseAngle;
73
           var rotation = initialRotation + newMouseAngle * (180 / Math.PI);
77
           var rotation = initialRotation + newMouseAngle * (180 / Math.PI);
74
-          el.data('tower').rotation = rotation;
78
+          tower.rotation = rotation;
75
           el.rotate(rotation);
79
           el.rotate(rotation);
76
         };
80
         };
77
 
81
 

Loading…
Cancel
Save