admin管理员组文章数量:1431034
I've created a Canvas and have written out a grid(resembles graph paper) with the X & Y coordinates successfully. What I'm looking to do now is the following:
-When someone clicks with a mouse a square in the grid will change to a different color
-Once a block is selected that data will not change
I've created a Canvas and have written out a grid(resembles graph paper) with the X & Y coordinates successfully. What I'm looking to do now is the following:
-When someone clicks with a mouse a square in the grid will change to a different color
-Once a block is selected that data will not change
1 Answer
Reset to default 6You need a separate 2D array that maintains the state for each (x, y) grid position.
When a click happens, check that state array to see if the cell was clicked before, and update the canvas as appropriate.
I created a little demo to show you: http://jsfiddle/alnitak/xN45K/
本文标签: javascriptHTML 5 CanvasGrid Block FillInStack Overflow
版权声明:本文标题:javascript - HTML 5 Canvas - Grid Block Fill-In - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745569907a2663984.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论