
对于动画/冷却时间等:如果要“等待”,但仍在运行代码,请使用:pygame.time.get_ticks
class Unit(): def __init__(self): self.last = pygame.time.get_ticks() self.cooldown = 300 def fire(self): # fire gun, only if cooldown has been 0.3 seconds since last now = pygame.time.get_ticks() if now - self.last >= self.cooldown: self.last = now spawn_bullet()
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)