• <tfoot id='iUj2v'></tfoot>

    <legend id='iUj2v'><style id='iUj2v'><dir id='iUj2v'><q id='iUj2v'></q></dir></style></legend>

        <bdo id='iUj2v'></bdo><ul id='iUj2v'></ul>

    1. <i id='iUj2v'><tr id='iUj2v'><dt id='iUj2v'><q id='iUj2v'><span id='iUj2v'><b id='iUj2v'><form id='iUj2v'><ins id='iUj2v'></ins><ul id='iUj2v'></ul><sub id='iUj2v'></sub></form><legend id='iUj2v'></legend><bdo id='iUj2v'><pre id='iUj2v'><center id='iUj2v'></center></pre></bdo></b><th id='iUj2v'></th></span></q></dt></tr></i><div id='iUj2v'><tfoot id='iUj2v'></tfoot><dl id='iUj2v'><fieldset id='iUj2v'></fieldset></dl></div>
    2. <small id='iUj2v'></small><noframes id='iUj2v'>

        按住键时如何进行精灵移动

        How can I make a sprite move when key is held down(按住键时如何进行精灵移动)

        <small id='bPnRB'></small><noframes id='bPnRB'>

          <tbody id='bPnRB'></tbody>

          <tfoot id='bPnRB'></tfoot>
            <i id='bPnRB'><tr id='bPnRB'><dt id='bPnRB'><q id='bPnRB'><span id='bPnRB'><b id='bPnRB'><form id='bPnRB'><ins id='bPnRB'></ins><ul id='bPnRB'></ul><sub id='bPnRB'></sub></form><legend id='bPnRB'></legend><bdo id='bPnRB'><pre id='bPnRB'><center id='bPnRB'></center></pre></bdo></b><th id='bPnRB'></th></span></q></dt></tr></i><div id='bPnRB'><tfoot id='bPnRB'></tfoot><dl id='bPnRB'><fieldset id='bPnRB'></fieldset></dl></div>
              <bdo id='bPnRB'></bdo><ul id='bPnRB'></ul>

                1. <legend id='bPnRB'><style id='bPnRB'><dir id='bPnRB'><q id='bPnRB'></q></dir></style></legend>
                2. 本文介绍了按住键时如何进行精灵移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  目前,每次按下一个键,精灵只会移动 1 个像素.按住左键或右键时,如何使水管工精灵不断移动?

                  Currently the sprite only moves 1 pixel every time a key is pressed. How could I cause the plumber sprite to move constantly when left or right key is being held down?

                  while running:
                      setup_background()
                      spriteimg = plumberright
                  
                      screen.blit(spriteimg,(x1, y1))
                  
                      for event in pygame.event.get():
                           if event.type == pygame.QUIT:
                               running = False
                           elif event.type == pygame.KEYDOWN:
                               if event.key == pygame.K_UP:
                                   x1 = x1 + 0
                                   y1 = y1 - 1
                               elif event.key == pygame.K_DOWN:
                                   x1 = x1 + 0
                                   y1 = y1 + 1
                               elif event.key == pygame.K_LEFT:
                                   x1 = x1 -1
                                   y1 = y1 + 0
                               elif event.key == pygame.K_RIGHT:
                                   x1 = x1 + 1
                                   y1 = y1 + 0
                  
                      pygame.display.flip()
                      clock.tick(120)
                  

                  推荐答案

                  你可以使用 pygame.key.get_pressed 这样做.

                  You can use pygame.key.get_pressed to do that.

                  示例:

                  while running:
                      keys = pygame.key.get_pressed()  #checking pressed keys
                      if keys[pygame.K_UP]:
                          y1 -= 1
                      if keys[pygame.K_DOWN]:
                          y1 += 1
                  

                  这篇关于按住键时如何进行精灵移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Is there a way of group by month in Pandas starting at specific day number?( pandas 有从特定日期开始的按月分组的方式吗?)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                    <i id='1rhde'><tr id='1rhde'><dt id='1rhde'><q id='1rhde'><span id='1rhde'><b id='1rhde'><form id='1rhde'><ins id='1rhde'></ins><ul id='1rhde'></ul><sub id='1rhde'></sub></form><legend id='1rhde'></legend><bdo id='1rhde'><pre id='1rhde'><center id='1rhde'></center></pre></bdo></b><th id='1rhde'></th></span></q></dt></tr></i><div id='1rhde'><tfoot id='1rhde'></tfoot><dl id='1rhde'><fieldset id='1rhde'></fieldset></dl></div>

                      <tbody id='1rhde'></tbody>

                      • <bdo id='1rhde'></bdo><ul id='1rhde'></ul>
                        <tfoot id='1rhde'></tfoot><legend id='1rhde'><style id='1rhde'><dir id='1rhde'><q id='1rhde'></q></dir></style></legend>

                            <small id='1rhde'></small><noframes id='1rhde'>