Skip to content
Advertisement

More than one draggable image events in Kinect

I’m creating a script with draggable images which change src when double clicked as : Draggable image event in Kinect

Earlier question was answered and works great though if I add another object which will also change src when double-clicked then nothing works.

What could be the problem?

Advertisement

Answer

You have to have a set of different image and click event. jsfiddle: http://jsfiddle.net/bighostkim/8BcXk/

    var imageObj2 = new Image();
    imageObj2.src = 'http://www.html5canvastutorials.com/demos/assets/yoda.jpg';
var yoda2 = new Kinetic.Image({
      x: 300,
      y: stage.getHeight() / 2 - 59,
      width: 106,
      height: 118,
      image: imageObj2,
      draggable: true
    });
    layer.add(yoda2);
    var imgIndex2 = 0;
    yoda2.on('click',function() {
        imageObj2.src = images[ imgIndex2++ % 3 ];
        layer.draw();
    })
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement