我正在尝试访问 ProcessingJS 片段中的mousePressed属性,但正在获取undefined
.
这是我到目前为止所尝试的:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="http://cloud.github.com/downloads/processing-js/processing-js/processing-1.4.1.min.js"></script>
<script>
$(document).ready(function() {
$('body').append($('<canvas id="preview"><p>Your browser does not support the canvas tag.</p></canvas>'));
function onPJS(p) {
p.setup = function(){
console.log(p.mousePressed);//prints undefined
try{
console.log(p.mousePressed());
}catch(e){
console.log(e.name,e.message);//prints TypeError Property 'mousePressed' of object [object Object] is not a function
}
}
}
new Processing(document.getElementById("preview"), onPJS);
});
</script>
关于我错过/做错了什么的任何线索?