简体   繁体   English

HTML5 canvas:processingJS

[英]HTML5 canvas :processingJS

i try to do some animation in HTML5 using processingjs , the problem is i try to attach event to for example a square at very low level ie by capturing X,Y mouse coordinate and compare with the clicked area . 我尝试使用processing.js在HTML5中制作一些动画,问题是我尝试将事件附加到例如非常低水平的正方形,即通过捕获X,Y鼠标坐标并与单击区域进行比较。

the question is there any way to attach event like we do in JavaScript or other lang ? 问题是,有没有办法像在JavaScript或其他lang中那样附加事件? if not , any other lib. 如果没有,则任何其他库。 or framework can help ? 还是框架可以帮助? because i feel this will not work when have many elements on the canvas . 因为我认为当画布上有许多元素时,这不会起作用。

You can use the "mouseClicked" function and check "mouseX" and "mouseY" variables inside. 您可以使用“ mouseClicked”功能并检查其中的“ mouseX”和“ mouseY”变量。 If have the square definition somewhere you can do a collision detection there. 如果在某处具有正方形定义,则可以在那里进行碰撞检测。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM