讓我們假設你有一個精靈組,並且添加了一堆東西出來:刪除/從sprites.Group取出前N個或最後N()
all_shelfs = pygame.sprite.Group()
shelf_tracking_list = []
#making shelfs
build_lvl = HEIGHT - 150
#group A
for i in xrange(100):
wid = random.randint(120,320)
pos = [random.randint(0, WIDTH-wid), random.randint(build_lvl-20, build_lvl), wid]
all_shelfs.add(Shelf(pos[0],pos[1], pos[2]))
build_lvl = build_lvl - 60
#group B
for i in xrange(100):
wid = random.randint(120,320)
pos = [random.randint(0, WIDTH-wid), random.randint(build_lvl-20, build_lvl), wid]
all_shelfs.add(Shelf(pos[0],pos[1], pos[2]))
build_lvl = build_lvl - 60
#group C
for i in xrange(100):
wid = random.randint(120,320)
pos = [random.randint(0, WIDTH-wid), random.randint(build_lvl-20, build_lvl), wid]
all_shelfs.add(Shelf(pos[0],pos[1], pos[2]))
build_lvl = build_lvl - 60
shelf_tracking_list = all_shelfs.sprites()
如何刪除集團例如? 這是我添加的第一個組。我注意到,使用這個shelf_tracking_list