创建对象后,KineticJS更改属性(NOOB)

时间:2012-08-09 12:06:39

标签: javascript html5 canvas properties kineticjs

大家好,我是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",
    });

并保持其他属性相同?

2 个答案:

答案 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);

它有效:)