是否可以在pygame内部“缩放”一个矩形。有点像当你在桌面上缩放你的窗口时,我想知道你怎么能在pygame中这样做。光标将控制矩形的大小。在
我用skrx方法,试着用两个矩形来做:
if evnt.type == MOUSEBUTTONDOWN:
if winVirus.collidepoint(evnt.pos):
rectVSelect = True
elif winCrime.collidepoint(evnt.pos):
rectCSelect = True
elif evnt.type == MOUSEBUTTONUP:
rectVSelect = False
rectCSelect = False
if evnt.type == MOUSEMOTION:
if rectVSelect:
winVirus.w += evnt.rel[0]
winVirus.h += evnt.rel[1]
winVirus.w = max(winVirus.w, 50)
winVirus.h = max(winVirus.h, 50)
elif rectCSelect:
winCrime.w += evnt.rel[0]
winCrime.h += evnt.rel[1]
winCrime.w = max(winVirus.w, 50)
winCrime.h = max(winVirus.h, 50)
但对于第二个矩形,它会正常移动,“wincreme”似乎有问题。“winVirus”非常好用。在
这是一个有效的例子。你得适应你的情况。在
您只需更改rect的宽度和高度(
w
和h
属性)。当鼠标移动时(队列中添加了一个MOUSEMOTION
事件),如果选择了rect,则将相对移动event.rel
添加到宽度和高度。在如果您想用多个rect来完成这个任务,您只需将单击的rect分配给一个变量(在本例中是
^{pr2}$selected_rect
),然后缩放它。在相关问题 更多 >
编程相关推荐