繁体   English   中英

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

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

我无法弄清楚如何在jCanvas中获得弓的当前旋转角度。 当我真的想改变它的行为时, layer.rotate似乎只为我提供了原来的旋转设置。

在jsfiddle上有一个示例设置来演示该问题。

任何见识将不胜感激。

您是否在寻找这个值$('#rot')。val()

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

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