简体   繁体   中英

Error 'str' object has no attribute 'blit'

I am not sure why this isn't working. Do I need a class?

Just for a random project, I have tried making a class, but not sure if I need to use (self) or something

I know that other people have had this question, but they all have classes and I am not sure I need this or how I can do it.

from pygame_functions import *
import pygame
import random




def Menu():

    screenSize(1280, 755)

    setBackgroundColour( [93, 173, 226] )

    PlayButton = makeSprite("filename") # put in file from photoshop

    # MoveSprite()

    showSprite(PlayButton)

    SettingsButton = makeSprite("filename") # put in setting button

    # MoveSprite()

    showSprite(SettingsButton)

    if spriteClicked(PlayButton):
        Difficulty()
        hideSprite(PlayButton)
        hideSprite(SettingsButton)

    if spriteClicked(SettingsButton):
        Settings()
        hideSprite(PlayButton)
        hideSprite(SettingsButton)
    else:
        showSprite(PlayButton)
        showSprite(SettingsButton)


def Settings():

    drawRect(440, 65, 400, 600, "Black")

    SoundButton = makeSprite("filename")

    SoundIcon = makeImage("filename") # On

    ScreenRes = makeSprite("filename")

    ScreenResIcon = makeImage("filename") # 1280x755

    List = int(0)

    if spriteClicked(SoundButton):
        changeSpriteImage(SoundIcon, "filename") # Off
    if spriteClicked(ScreenRes):
        if List == 4:
            List = 0
        else:
            if List == 0:
                changeSpriteImage(ScreenResIcon, "Filename") # 1280x755
                List = List + 1
            elif List == 1:
                changeSpriteImage(ScreenResIcon, "Filename") # 1366x768
                List = List + 1
            elif List == 2:
                changeSpriteImage(ScreenResIcon, "Filename") #1920x1080
                List = List + 1
            elif List == 3:
                changeSpriteImage(ScreenResIcon, "Filename") # 320x568
                List = List + 1


def Difficulty(Range):

    Hard = makeSprite("FileName") # hard button

    showSprite(Hard)

    Medium = makeSprite("Filename")

    showSprite(Medium)

    Easy = makeSprite("Filename")

    showSprite(Easy)

    range = int(0)

    if spriteClicked(Hard):
        Game()
        Range = int(51)# 50
    elif spriteClicked(Medium):
        Game()
        Range = int(26)# 25
    elif spriteClicked(Easy):
        Game()
        Range = int(11)# 10
    range = Range


def Game(Range):

    setBackgroundColour("Blue")

    # after all the visual stuff
    random.randint(1, Range)


endWait()

I think that your import statement should be from pygame.locals import* , not from pygame.functions import*

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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