【发布时间】:2014-09-23 00:58:27
【问题描述】:
我正在制作一个应用程序,用户可以在其中将多个对象从工具栏拖放到画布上。将特定对象拖放到画布上后,用户可以在画布中移动该对象。双击该对象将使它消失。我已经能够为工具栏中的一个对象实现这一点,如下面的链接所示..
为了从工具栏中拖放多个对象,我在函数 DragDrop() 中添加了以下内容
var image2 = new Kinetic.Image({
name: data,
id: "image"+(imageCount++),
x: x,
y: y,
image2: theImage2,
draggable: true
});
image2.on('dblclick', function() {
image2.remove();
layer.draw();
});
layer.add(image2);
layer.draw();
var image3 = new Kinetic.Image({
name: data,
id: "image"+(imageCount++),
x: x,
y: y,
image3: theImage3,
draggable: true
});
image3.on('dblclick', function() {
image3.remove();
layer.draw();
});
layer.add(image3);
layer.draw();
包含上述代码的Fiddle是http://jsfiddle.net/gkefk/29/
即使我在 DragDrop() 函数中进行了必要的添加,这两个新对象在工具栏中仍然可见,但我无法像第一个对象那样拖放、移动和删除它们。请帮忙...
【问题讨论】:
标签: javascript jquery canvas kineticjs