0
<script type="text/paperscript" canvas="paper">
function onKeyDown(event) {
alert('key pressed');
function onFrame(event) {
console.log('frames running');
}
}
</script>
下面的代碼有效,但上面沒有。爲什麼onFrame事件在用作語句時不會觸發?paperjs:爲什麼onFrame事件不在onKeyDown事件中工作?
function onKeyDown(event) {
alert('key pressed');
view.onFrame = function(event) { //This line is makes a difference
console.log('frames running');
}
}
此外,在下面的代碼中,如果我使用view.onFrame方法,圓形縮小但在另一個鍵被按下時突然停止。
function onKeyDown(event) {
var circle = new Path.Circle((view.size * Point.random()), 50);
circle.fillColor = 'purple';
view.onFrame = function(event) {
circle.scale(.9);
}
}