pygame鼠标
✕
游戏鼠标的操作大多我们关注的是移动,点击等,pygame有两种(我晓得的)获取鼠标位置,点击。
获取鼠标移动方法1:
事件获取鼠标位置,键按下,弹起,
# 鼠标位置
event.type ==pygame.MOUSEMOTION# 鼠标按下
event.type ==pygame.MOUSEBUTTONDOWN# 鼠标弹起event.type ==pygame.MOUSEBUTTONUP
捕获的事件中,
鼠标位置是:
ifevent.type ==pygame.MOUSEMOTION:# print("移动")
# print(event.pos) # 查看移动的坐标
鼠标按下是:
左 = 1 滑轮 =2 右键=3
ifevent.button ==1:
print("鼠标左键按下")
elifevent.button ==3:print("鼠标右键按起")
鼠标抬起是:
左 = 1 滑轮 =2 右键=3
ifevent.button ==1:print("鼠标左键抬起")
elifevent.button ==3:
print(