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 .
the question is there any way to attach event like we do in JavaScript or other 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. If have the square definition somewhere you can do a collision detection there.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.