1
나는 드래그 가능한 10 개의 직사각형을 추가했으며 하나씩 클릭하면 제거 할 수 있기를 원합니다. 지금은 처음 것만 제거하면 더 이상 제거되지 않습니다. 사각형 이벤트에 클릭 이벤트를 추가 할 수 있습니까?Kineticjs 여러 모양 제거
var stage = new Kinetic.Stage({
container: 'container',
width: 578,
height: 400
});
var layer = new Kinetic.Layer();
for (var i = 0; i< 10; i++) {
var rect = new Kinetic.Rect({
x: 239 + (i *3),
y: 75 + (i * 3),
width: 100,
height: 50,
fill: 'blue',
stroke: 'black',
strokeWidth: 4,
draggable: true,
id: i
});
rect.on('click', function() {
rect.hide();
});
// add the shape to the layer
layer.add(rect);
// add the layer to the stage
stage.add(layer);
}
그래, 진짜 범인은 오히려 rect.remove(), 좋은 일보다는 this.remove()를 사용하는 것 – SoluableNonagon