我有以下对象:
thegirls.onload = function() {
thegirls = new Kinetic.Image({
x: 50,
y: 30,
image: thegirls,
width: 106,
height: 118
});
layer2.add(thegirls);
layer2.draw();
}
thegirls.src = "01.png";
我想创建一个更改图像的功能,但我无法更改图片
代码:
function changegirls (){
thegirls.src = "02.png";
layer2.draw();
}
感谢所有
答案 0 :(得分:0)
您可以使用.setImage来更改Kinetic.Image的图像
var kGirls;
thegirls.onload = function() {
kGirls = new Kinetic.Image({
x: 50,
y: 30,
image: thegirls,
width: 106,
height: 118
});
layer2.add(kGirls);
layer2.draw();
}
thegirls.src = "01.png";
function changegirls (){
var img02=new Image();
img02.onload=function(){
kGirls.setImage(img02);
layer2.draw();
}
img02.src = "02.png";
}