浏览代码

Double click to delete towers

master
Chris Smith 12 年前
父节点
当前提交
089f952c45
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5
    1
      index.html

+ 5
- 1
index.html 查看文件

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

正在加载...
取消
保存