'Group' object has no attribute 'xxx'

quote text-sharp-sharp-sharp title description
I want to create a spaceship that can fire bullets. According to the book, it always shows
AttributeError: "Group" object has no attribute" control bullets"
Please have a look and beg on your knees

sources of topics and their own ideas

related codes

import pygame
from pygame.sprite import Sprite
class Bullet(Sprite):
    def __init__(self,a,,):
        super().__init__()
        self. = 
        self. = pygame.Rect(0,0,a.,a.)
        self..centeyx = ..centerx
        self..top = ..top
        self.y =(self..y)
        self.= a.
        self. = a.

    def (self):
        self.y -= self.
        self..y = self.y
        
    def (self):
        pygeme.draw.rect(self.a,self.,self.)
        
```

    


----------


```

import sys
import pygame
from  import Bullet
def (,,):
    -sharp
    .fill(a.)
    .()
 
    -sharp
    pygame.display.flip()
def (,,,a):                                                                                                                                                                                
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        elif event.type == pygame.KEYDOWN: 
           (event,,,,a)
        elif event.type == pygame.KEYUP:
            (event,)
    
def (event,,,,a):
    if  event.key == pygame.K_RIGHT:
        .a = True
    elif event.key == pygame.K_LEFT:
        .b = True
    elif event.key == pygame.K_SPACE:
         = Bullet(a,,)
        .add()
   

def (event,):
    if event.key == pygame.K_RIGHT:
        .a = False
    elif event.key == pygame.K_LEFT:
        .b = False


----------


----------
import sys
import pygame
from  import 
from  import Ship
import  as l
from pygame.sprite import Group
def ():
    -sharp
    a=()
    -sharp
     = pygame.display.set_mode((a.,a.))
    -sharp
    pygame.display.set_caption("")
     = Group()
     = Ship(,a)
    while True:
        l.(,a,,)
        .()
        .()
        l.(,,a,)
        
            
()

what result do you expect? What is the error message actually seen?

I don"t know much English, so I change everything that can be replaced by Chinese to Chinese. Not all the code is posted, because there are no changes left, and errors should appear in these three pieces of code.
Traceback (most recent call last):
File "C: war Aliens Game .py", line 23, in < module >

()

File "C: war Aliens Game. Py", line 19, in start the game

.()

AttributeError: "Group" object has no attribute" control bullet
this is the wrong prompt, kneel and beg for kindness.
I can"t find the error after looking for it all afternoon

Mar.18,2022

the main code missed the pygame.inint complex Group egg pain report.


the problem is here

 = Group()
 = Ship(,a)
while True:
    l.(,a,,)
    .()
    .()
    l.(,,a,)

bullet group is an object instantiated by pygame.sprite.Group . How can there be control bullet () this method

pygame.sprite.Group

so it should be bullet group = Group () instantiation is wrong here. Control bullet () method only Bullet object has


def update_bullets (bullets):

for bullet in bullets.sprites():    -sharp group
    bullet.update_position()

-sharp 
for bullet in bullets.copy():
    if bullet.rect.bottom <= 0:
        bullets.remove(bullet)

this place should be incorrect in passing parameters
bullet does not have a corresponding rect attribute,
does not create a new bullet correctly
should be a parameter error when calling the method that created the bullet
check this

Previous: How does JS determine that all requests in an asynchronous queue are completed?

Next: The current version of Wechat, jssdk configuration of sharing, as long as the click of the share button will trigger success how to break ah?

Menu