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/
JavaScript
x
17
17
1
var imageObj2 = new Image();
2
imageObj2.src = 'http://www.html5canvastutorials.com/demos/assets/yoda.jpg';
3
var yoda2 = new Kinetic.Image({
4
x: 300,
5
y: stage.getHeight() / 2 - 59,
6
width: 106,
7
height: 118,
8
image: imageObj2,
9
draggable: true
10
});
11
layer.add(yoda2);
12
var imgIndex2 = 0;
13
yoda2.on('click',function() {
14
imageObj2.src = images[ imgIndex2++ % 3 ];
15
layer.draw();
16
})
17