简体   繁体   English

即使看起来正确也无法创建表面

[英]cannot create surface even though it seems correct

self.image = pygame.Surface(
                int(math.sqrt((end_pos[1] - start_pos[1])**2 +(end_pos[0] - start_pos[0])**2)),  width)

returns the error:返回错误:

 ValueError: size needs to be (int width, int height)

The argument to the constructor of pygame.Surface is a tuple with the size of the Surface ( pygame.Surface((with, height)) ): pygame.Surface的构造函数的参数是一个具有Surface大小的元组( pygame.Surface((with, height)) ):

self.image = pygame.Surface(int(math.sqrt((end_pos[1] - start_pos[1])**2 +(end_pos[0] - start_pos[0])**2)), width)

self.image = pygame.Surface(
    (int(math.sqrt((end_pos[1] - start_pos[1])**2 +(end_pos[0] - start_pos[0])**2)),  width))

respectively分别

value = int(math.sqrt((end_pos[1] - start_pos[1])**2 +(end_pos[0] - start_pos[0])**2))
self.image = pygame.Surface((value, width))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM