2013-12-20 57 views
0

我有动力学Rect的以下代码,为什么我无法调整rect的大小,虽然我调整了rect中定义的属性的大小。Javascript kinetics:rect调整大小

var stage = new Kinetic.Stage({ 
    container: 'container', 
    width: 578, 
    height: 200 
    }); 

    var layer = new Kinetic.Layer(); 

    var rect = new Kinetic.Rect({ 
    x: 239, 
    y: 75, 
    width: 100, 
    height: 50, 
    fill: 'green', 
    stroke: 'black', 
    strokeWidth: 4, 
    resize: true 
    }); 

    // add the shape to the layer 
    layer.add(rect); 

    // add the layer to the stage 
    stage.add(layer); 

回答

1

KineticJS没有resize属性。

你必须手动调整:

rect.setSize(newWidth,newHeight); 
layer.draw(); 
+0

我怎么能看到相关层的所有属性?有没有kinectics API文件? – user84592

+0

如何让rect获得onclick事件? – user84592

+0

以下是关于KineticJS的一些很好的教程:http://www.html5canvastutorials.com/kineticjs/html5-canvas-path-mouseover/这里是文档(警告:文档似乎是自动生成的,导致一些类**说**他们允许某些属性/方法,但他们真的没有) – markE