使 html5 canvas 具有交互性

发布于 2024-12-22 18:09:43 字数 343 浏览 0 评论 0原文

可能的重复:
如何获取鼠标点击画布元素的坐标?

我还有另一个关于 html5 画布的问题。 我已经使用 Javascript 中的此功能制作了几个很酷的项目,但我现在正在寻找使用鼠标使画布更具交互性的方法。 我需要的只是一种将变量设置为鼠标的 x 值或其 y 值的简单方法。

谢谢!

Possible Duplicate:
How do I get the coordinates of a mouse click on a canvas element?

I have yet another question regarding the html5 canvas.
I've been making several cool projects with this feature in Javascript, but I'm now looking for ways to use the mouse to make the canvas more interactive.
All I need is a simple way to set a variable to either the mouse's x value, or its y value.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妥活 2024-12-29 18:09:44

HTML5 Canvas只是一个绘图平面,没有显示列表。要使用 x、y 和其他属性添加、删除、放置对象,首先需要为容器和可添加到容器的对象定义类。您要么必须自己开发它,要么可以使用任何一个可用的库。

http://easeljs.com/

http://www.kineticjs.com/

几个月前,我也开始开发一个用于相同目的的库。我遇到了很多性能问题,因此等待一些空闲时间来优化我的代码。您可以在这里找到该库 https://github.com/tracevipin/exsprite 以及一些演示http://www.exsprite.com/demos/

HTML5 Canvas is just a drawing plane and there is no display list. To add, remove, place objects using x,y and other properties first you need to define classes for containers and objects that can be added to the containers. Either you have to develop it yourself or you can use any one of the libraries available.

http://easeljs.com/

http://www.kineticjs.com/

A few months before I also started developing one library for the same purpose. I faced a lot of performance issues, so waiting for some free time to optimize my code. You can find the library here https://github.com/tracevipin/exsprite and some demos here http://www.exsprite.com/demos/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文