Hi,
I have recently learned about sprite groups. While they are documented and described as extremely helpful when working with more than one sprite of a particular type, I seem to have noticed there is something sprite groups wont allow me to do, which makes me feel like they are pointless to work with.
Let's say I have a unit class that gets a circle drawn around the unit when it is selected, I would put this in my class' draw method:
def draw(self):
screen.blit(self.image, self.rect)
if self.selected:
pygame.draw.circle(screen, (0, 255, 0), self.center, 6)
Pretty simple right?
Well the sprite group draw method does this:
"Draws the contained Sprites to the Surface argument. This uses the Sprite.image attribute for the source surface, and Sprite.rect for the position."
What this is saying is that it will only draw the image, not everything I want drawn along with it inside the draw method (which can potentially be HP Bars, Selection Rings, any more).
Should I just do away with sprite groups entirely and do everything like this?
[...]
myObjects = []
[...]
for object in myObjects:
object.update()
for object in myObjects:
object.draw()