Why is my PyGame Sprite, in a Group, not drawn - AttributeError: 'Group' object has no attribute 'blitme'

后端 未结 1 1949
别那么骄傲
别那么骄傲 2020-12-04 03:17

I am a beginner for pygame and I am imitating the game code "alien invasion" in the book "Python Crash Course" to program a game named "Alphabet zoo

相关标签:
1条回答
  • 2020-12-04 04:02

    The method blitme doesn't exist in pygame.sprite.Group. You cannot invoke a method on a pygame.sprite.Group object, that doesn't exist. But you don't need blitme at all. All you have to do is to invoke pygame.sprite.Group.draw():

    Draws the contained Sprites to the Surface argument. This uses the Sprite.image attribute for the source surface, and Sprite.rect for the position.

    For instance:

    letters.draw()
    

    pygame.sprite.Group.draw() and pygame.sprite.Group.update() are methods which are provided by pygame.sprite.Group. The former delegates the to the update mehtod of the contained pygame.sprite.Sprites - you have to implement the method. The later uses the image and rect attributes of the contained pygame.sprite.Sprites to draw the objects - you have to ensure that the pygame.sprite.Sprites have the required attributes.

    0 讨论(0)
提交回复
热议问题