小编hen*_*nry的帖子

在pygame中将矩形转换为曲面

在我的代码中它不断给我错误:

pygame.surface.Surface.blit(a, (x1, y1))

类型错误:描述符“blit”需要“pygame.Surface”对象,但收到“pygame.Rect”。

帮助!

这是我的代码:

import pygame
import time

pygame.init()

screen = pygame.display.set_mode()

display_width = 1366
display_height = 768

white = (255,255,255)
red = (255,0,0)
green = (0,255,0)

gameDisplay = pygame.display.set_mode((display_width,display_height))
clock = pygame.time.Clock()

global x1
global y1
global x2
global y2

x1 = 683
y1 = 384
x2 = 0
y2 = 500


def game():
    y1 = 384
    gameDisplay.fill(white)
    a = pygame.draw.rect(gameDisplay, red, (x1,y1,250,250), 0)
    b = pygame.draw.rect(gameDisplay, green, (x2,y2,100,100), 0)
    pygame.display.update()
    gameStart = True
    while gameStart …
Run Code Online (Sandbox Code Playgroud)

python pygame surface rect blit

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

blit ×1

pygame ×1

python ×1

rect ×1

surface ×1