This topic is READ ONLY
ZhangXunqi (8) [Avatar] Offline
#1
Hi~
I have another question:
In example 17.1:import sys,pygame
class MyBallClass(pygame.sprite.Sprite):
def __init__(self,image_file,location):
pygame.sprite.Sprite.__init__(self)
self.image=pygame.image.load(image_file)
self.rect=self.image.get_rect()
self.rect.left,self.rect.top=location
size=width,height=640,480
screen=pygame.display.set_mode(size)
screen.fill([255,255,255])
img_file="beach_ball.png"
balls=[]
for row in range (0,3):
for column in range (0,3):
location=[column*180+10,row*180+10]
ball=MyBallClass(img_file,location)
balls.append(ball)
for ball in balls:
screen.blit(ball.image,ball.rect)
pygame.display.flip()
while True:
for event in pygame.event.get():
if event.type==pygame.QUIT:
sys.exit()



In line 2:I used see nothing after class's name(except ':'),why there is a pair of parenthesis and what's 'pygame.sprite.Sprite'?