大家好,我是KineticJS的菜鸟,我想知道如何更改属性值。例如,创建后的矩形:
var rect = new Kinetic.Rect({
x: 239,
y: 75,
width: 100,
height: 50,
fill: "#00D2FF",
stroke: "black",
strokeWidth: 4
});
我将如何做这样的事情:
rect.NewProperty({
x: 100,
y: 30,
width: 100,
height: 50,
fill: "#cccccc",
});
并保持其他属性相同?
答案 0 :(得分:2)
像这样:
var rect = new Kinetic.Rect({
x: 239,
y: 75,
width: 100,
height: 50,
fill: "#00D2FF",
stroke: "black",
strokeWidth: 4
});
rect.setFill("#D200FF");
rect.setStrokeWidth(1);
答案 1 :(得分:1)
感谢信息..
我也试过
rect.setWidth(100);
和
rect.setHeight(100);
它有效:)