2014-03-06 54 views
0

我知道transitionTo不再是Kinetic中的支持函数。所以,我的问题是,我如何去旋转文字?我有一个id为'rotate'的文本,它需要垂直,而其余文本保持水平。所以,由于transitionTo不再有用,我该如何旋转此文本?旋转动力文本

$(xml).find("text").each(function(){       
    var coords = $(this).attr("transform"); 
    var matrix = coords.split(" "); 
    var textX = parseInt(matrix[4]); 
    var textY = matrix[5]; 
    textY = parseInt(textY.substr(0, textY.length - 1)); 

    var font = parseInt($(this).attr("font-size")); 
    var tspan = $(this).find("tspan"); 
    var type = $(this).attr("id"); 

    if(typeof $(this).attr("font-size") == "undefined"){ 
     font = parseInt(tspan.attr("font-size")); 
    } 

    if(typeof type !== "undefined"){ 
     if(type.substr(0,5) == "rotate"){ 
      type = "rotate"; 
     } 
    } 

    if(type == 'rotate'){ 
     text.transitionTo({ 
      rotation: 270 
     }); 
    } 
    text = new Kinetic.Text({ 
     x: textX, 
     y: textY, 
     text: full_text, 
     fontSize: font, 
     fontFamily: 'Arial', 
     fill: 'black', 
     align: talign 
    }); 
}); 

回答

1

使用Kinetic.Tween的现在:

var tween = new Kinetic.Tween({ 
    node: text, 
    duration: 1, 
    rotation: 270 
}); 

tween.play(); 
+0

我并不需要它虽然动画,我把文本从SVG/AI文件,问题是,文本不来了旋转。 – User

+1

然后只是做:text.rotation(270):) – markE

+0

我明白了,用不同的方式。不过谢谢。 – User