我应该怎么做才能防止我的角色一直在跳跃?

问题描述

我的问题是我的角色一直在跳跃。我怎样才能防止这种情况?

我的问题视频:https://www.youtube.com/watch?v=QwmAdzEJH-0

这是我的代码(我认为这部分是错误的):

hitBox = pygame.draw.rect(win,(255,255,255),self.hitBox,1)
first_rect = pygame.draw.rect(win,(0,0),[385,465,117,75])
second_rect = pygame.draw.rect(win,[494,390,120,80])
ucuncu_rect = pygame.draw.rect(win,[596,308,84])
dorduncu_rect = pygame.draw.rect(win,[701,240,270,70])
if hitBox.colliderect(first_rect):
   if abs(first_rect.left - hitBox.right) < 10:
      self.x -= 10
   elif abs(first_rect.top - hitBox.bottom) < 10:
      self.y = 314
if hitBox.colliderect(second_rect):
   if abs(second_rect.left - hitBox.right) < 10:
       self.x -= 5
   elif abs(second_rect.top - hitBox.bottom) < 60:
       self.y -= 70
if hitBox.colliderect(ucuncu_rect):
   if abs(ucuncu_rect.left - hitBox.right) < 10:
       self.x -= 5
   elif abs(ucuncu_rect.top - hitBox.bottom) < 55:
       self.y -= 41
if hitBox.colliderect(dorduncu_rect):
   if abs(dorduncu_rect.left - hitBox.right) < 10:
       self.x -= 5
   elif abs(dorduncu_rect.top - hitBox.bottom) < 55:
       self.y -= 35
elif (self.y < 450) and (self.isJump == False):
   self.y += 10

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)