MouseMove event too slow for painting

孤者浪人 提交于 2019-12-22 07:59:39

问题


I'm using C# WinForms to create a level builder for my XNA game. I have a tile grid that you can paint with a Pencil tool, like in MSPaint. The problem is that when you drag the mouse fast(ish) to paint a line tiles get skipped.

I've tried using one approach i saw on Google saying to spawn a thread to do the painting, but that didn't seem to help.

Any ideas?


回答1:


OTTOMH, you could keep track of the last point the mouse was and in your MouseMove handler you can assume linear motion and determine all the tiles between the last point and the current point. My guess is that you're not likely to ever get enough MouseMove events to fire to handle the case where the user moves his mouse very quickly.




回答2:


Awesome! worked perfectly.

I used the DDA line algorithm from here

http://www.cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html

to draw the line.

Thanks!!



来源:https://stackoverflow.com/questions/404094/mousemove-event-too-slow-for-painting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!