-1
import pygame, sys, time, random

from pygame.locals import*

pygame.init()

class Button(object):

def __init__(self, x, y):
    '''x_size, y_size,'''
    #self.name = name
    '''self.length = x_size'''
    '''self.height = y_size'''
    self.xpos = x
    self.ypos = y
    self.rect = (100,100)
    self.image = ('Images\Button_Test.png')

def getRect(self):
    return self.rect


def onClick():
    for event in pygame.event.get():
        if event.type == pygame.mouse.get_pressed():
            pos = pygame.mouse.get_pos()
            if self.collidepoint(pos):
                return

主班

screen.blit(background,(0,0))
screen.blit(testButton, testButton.getRect())
pygame.display.flip()

TypeError:参数 1 必须是 pygame.Surface,而不是 Button

谁能帮我解决这个错误?

4

1 回答 1

0

尝试这个:

screen.blit(testbutton.image,testbutton.get_rect())

您当前正在将其告诉blit对象而不是对象的精灵

于 2016-01-12T22:27:04.993 回答