2013-02-27 84 views
0

我想順時針和逆時針旋轉我的形狀,具體取決於我移動鼠標的方向。這裏是樣本有點我知道不完全完美..如果可能,編輯我的偏移量和旋轉部分。這裏是fiddlekineticjs中的旋轉os形狀

回答

0

你可以做這樣的事情做有條件的旋轉:(僞代碼和實際代碼混合)

var currentRotation = shape.getRotation(); 
    var direction = ..stuff.. ; // your logic for mouse movement, result should be 1 or -1 
    var rotationAmount = 0.5; 

    shape.setRotation(currentRotation + direction * rotationAmount); //get current rotation and add/subtract some arbitrary amount 

如果你需要一個偏移量,你可以這樣做:

shape.setOffset(x,y);