简体   繁体   English

如何使用jCanvas动画获得当前旋转角度?

[英]How do I get the current rotation angle with jCanvas animation?

I can't figure out how to get the current rotation angle of an arch in jCanvas. 我无法弄清楚如何在jCanvas中获得弓的当前旋转角度。 layer.rotate only seems to provide me with the original setting of rotate, when I'd really like to change its behavior when it hits a certain angle. 当我真的想改变它的行为时, layer.rotate似乎只为我提供了原来的旋转设置。

I have an example setup on jsfiddle to demonstrate the problem. 在jsfiddle上有一个示例设置来演示该问题。

Any insight would be appreciated. 任何见识将不胜感激。

are you looking for this value $('#rot').val() 您是否在寻找这个值$('#rot')。val()

while (i < 1000) {
        setTimeout(function() { rotate() }, 1000);
        alert( $('#rot').val());
        i += 1;
    }

The animateLayer() and animateLayerGroup() methods support the same alternate syntax as jQuery's animate() method, which allows for a step callback: animateLayer()animateLayerGroup()方法支持与jQuery的animate()方法相同的备用语法,该语法允许进行step回调:

// Cache canvas element
var $canvas = $("canvas");

// Draw and animate
$canvas.drawArc({
  layer: true,
  name: 'arcy',
  fillStyle: "#000",
  x: 100, y: 100,
  radius: 50,
  start: 135, end: 45
});
$canvas.animateLayer('arcy', {
  rotate: 360
}, {
  // Use the step callback to run a function on every frame
  step: function(now, fx, layer) {
    console.log(layer.rotate);
  }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM