Reputation: 201
Here is a sample of my code:
if not pygame.sprite.collide_rect(yolo,blocks):
screen.blit(moonCollect, [randomListX[i]-stageBackground_x, randomListY[i]])
I have two sprites and right now only WHILE they collide, moonCollect disappears. How can I fix the logic so that moonCollect will not appear DURING and AFTER collision?
Appreciate any help, and tell me if I am being unclear.
Thanks
Upvotes: 3
Views: 46
Reputation: 2103
If I understand your question correctly then:
if pygame.sprite.collide_rect(yolo,blocks):
should fix the problem.
Edit: (this is probably wrong, the way you phrased it made me think you wanted the opposite to happen)
Upvotes: 0
Reputation: 1974
you could create a variable to represent if moon has ever collided with your object
isMoon = false
if pygame.sprite.collide_rect(yolo,blocks):
isMoon = true
//when rendering
if (isMoon == false):
screen.blit(moonCollect, [randomListX[i]-stageBackground_x, randomListY[i]])
This way, even when your moonCollect is not colliding with a object, but in the past it has, it will not be rendered.
Upvotes: 2