Reputation: 65
I have the following problem in pygame.I got pygame surface usingsurf=pygame.display.get_ surface()
,but when I am trying to call
surf.fill()
It says:
None type have no attribute fill
Upvotes: 0
Views: 345
Reputation: 64
I think your method "fill()" needs a color argument:
fill() fill Surface with a solid color fill(color, rect=None, special_flags=0) -> Rect
the documentation: https://www.pygame.org/docs/ref/surface.html#pygame.Surface.fill
Upvotes: 0
Reputation: 101042
You have to set a display mode first with pygame.display.set_mode
.
Otherwise, pygame.display.get_surface()
will return None
:
pygame.display.get_surface()
Get a reference to the currently set display surface
get_surface() -> Surface
Return a reference to the currently set display Surface. If no display mode has been set this will return None.
Also, you usually don't need that function, since set_mode
already returns the display Surface
.
Upvotes: 1