我试图了解如何将 setInterval 与 Paper.js 一起使用。我做了一个简单的测试,在 setInterval 函数内部和外部使用相同的代码。它适用于后一种情况,但不适用于 setInterval 内。任何想法?
// interval (not working)//
var id = setInterval(function() {
var path = new Path.Circle(new Point(20, 20), 30);
path.fillColor = 'red';
var pointX = 80;
var pointY = 50;
var symbol = new Symbol(path);
symbol.place(new Point(pointX, pointY));
pointX = pointX+50;
pointY = pointY+50;
}
}, 1000);
//no interval//
var path = new Path.Circle(new Point(20, 20), 30);
path.fillColor = 'red';
var pointX = 80;
var pointY = 50;
var symbol = new Symbol(path);
symbol.place(new Point(pointX, pointY));
pointX = pointX+50;
pointY = pointY+50;
symbol.place(new Point(pointX, pointY));
http://jsfiddle.net/miguelrivero/2BzUL/10/
谢谢!