小白随笔5946

导航

Pygame第一个事件on_mouse_down & collidepoint

参考:

https://pygame-zero.readthedocs.io/en/stable/introduction.html

------------------------------------------------

import pgzrun

alien = Actor('alien')
alien.pos = 100,56

WIDTH = 500
HEIGHT = alien.height + 40

def draw():
alien.draw()

def on_mouse_down(pos):
if alien.collidepoint(pos):
print("Eek!")
else:
print("You missed me!")

pgzrun.go()

--------------------------------------------

 

 def on_mouse_down(pos, button):

    if button == mouse.LEFT and alien.collidepoint(pos):

   print("Eek!")

 

 

posted on 2021-09-30 10:35  小白随笔5946  阅读(659)  评论(0编辑  收藏  举报