簡體   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)

返回錯誤:

 ValueError: size needs to be (int width, int 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))

分別

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