简体   繁体   English

我如何开始通过触摸一个画布来拖动几个画布之一

[英]how can i start dragging one of several drawn canvas by touching that one

I am trying to make a game.i want to move one of two canvas element. 我正在尝试制作游戏。我想移动两个画布元素之一。 i have drawn one circle and one rectangle and i want to drag rectangle. 我画了一个圆和一个矩形,我想拖动矩形。 Thanks in advance. 提前致谢。

HTML5 Canvas is actually like a bitmap. HTML5 Canvas实际上就像一个位图。 You can set the colors of the pixels in it. 您可以设置其中像素的颜色。 So whatever you draw becomes pixels. 因此,无论您画什么,都会变成像素。 ie an object will not be created. 即将不会创建对象。 So if you need objects on Canvas and modify the Canvas content by modifying the properties (x, y, rotation etc.) of the objects you have to develop your own system which manages graphics on Canvas using objects. 因此,如果您需要在Canvas上使用对象并通过修改对象的属性(x,y,旋转等)来修改Canvas内容,则必须开发自己的系统,该系统使用对象来管理Canvas上的图形。 This system should clear and update the Canvas pixels using the properties of the objects. 该系统应使用对象的属性清除并更新Canvas像素。 You will also have to create a display list to manage objects properly. 您还必须创建一个显示列表以正确管理对象。

There are also a few libraries available for the same purpose 也有一些用于相同目的的库

http://createjs.com/#!/EaselJS http://createjs.com/#!/EaselJS

http://www.kineticjs.com/ http://www.kineticjs.com/

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

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