pygame中没有类型变量可以被“填充”

时间:2018-12-24 13:58:21

标签: python-3.x pygame

我正在学习pygame,并且一直关注this tutorial.

似乎有问题:

  • 我在__初始化__中定义了一个变量-> _display_surf = None ...
  • 要执行以下命令:self._display_surf.fill((0,0,0)) 呈现黑色背景。

尽管如此,我仍然收到此错误:

Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "snake.py", line 86, in <module>
   theApp.on_execute()
  File "snake.py", line 79, in on_execute
   self.on_render()
  File "snake.py", line 49, in on_render
   self._display_surf.fill((0,0,0))
 AttributeError: 'NoneType' object has no attribute 'fill'

我的问题:我声明的变量应为哪种类型?

1 个答案:

答案 0 :(得分:0)

__ init __中的

# get all tracts in monmouth county language_tract <- get_acs(geography = "tract", variables = vars, state = "NJ", county = "Monmouth", geometry = TRUE, summary_var = "C16002_001", output = "wide") # get geometry of red bank borough red_bank_place <- places("NJ", cb = TRUE, class = "sf") %>% filter(NAME == "Red Bank") # only tracts in red bank borough red_bank_tracts <- language_tract %>% filter(st_contains(red_bank_place, ., sparse = FALSE)) ggplot() + geom_sf(data = red_bank_tracts, color = "blue", fill = NA) + geom_sf(data = red_bank_place, color = "black", fill = NA) 完成了工作:变量变为pygame.Surface()