Skip to content

Incorrectly documented DirtySprite.visible behavior (2475) #1271

Open
@GalacticEmperor1

Description

@GalacticEmperor1

Issue №2475 opened by BirdLogics at 2021-02-09 22:53:09

Description

Setting the visible property of a pygame.sprite.DirtySprite modifies the dirty attribute, despite the docs stating "you must set it dirty too to be erased from screen." Either the docs should be fixed or the behavior should be changed to match them.

If someone updates visible when it doesn't need updating (as I've done), it will cause unnecessary screen updates. In my case, a large sprite used for the background image was causing the entire screen to be redrawn each frame.

Test code


import pygame



sprite = pygame.sprite.DirtySprite()

sprite.dirty = 0



print(sprite.dirty, sprite.visible)

sprite.visible = 1

print(sprite.dirty)

Output


pygame 2.0.1 (SDL 2.0.14, Python 3.8.3)

Hello from the pygame community. https://www.pygame.org/contribute.html

0 1

1


Comments

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugNot working as intendeddocsspritepygame.sprite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions