我创建了一个Kineticjs Circle形状,即我缩放。我用anim.start();开始缩放alarmcircle。 知道我是否可以设置缩放动画的持续时间(ex 2秒)。 我想要的是将alarmcircle设置为持续2秒的比例。
var period = 2000;
var anim = new Kinetic.Animation(function(frame) {
var scale = Math.sin(frame.time * 2 * Math.PI / period) + 0.001;
alarmcircle.scale({x:scale,y:scale});
}, layer);
anim.start();
答案 0 :(得分:0)
<script>
var period = 2000 ;
var anim = new Kinetic.Animation({
func: function(frame) {
if (frame.time >= period ) {
anim.stop() ;//this will last for 2s and then as soon as the frame time passes 2s it will stop
} else {
var scale = Math.sin(frame.time * 2 * Math.PI / period) + 0.001;
alarmcircle.scale({x:scale,y:scale});
}
},
node: layer
});
anim.start();
</script>