微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

pygame 忘记了图像是什么

如何解决pygame 忘记了图像是什么

我正在尝试在窗口上绘制一个小图像。 问题是,当我运行代码时,会弹出这个。

    AttributeError: 'pygame.Surface' object has no attribute 'image'
    
    anyway here the code.
    
    import pygame,sys,os,math

    pygame.init()
    runing_left = False
    runing_right = False
    screen_Width_heigth = (1920,1020)

    screen = pygame.display.set_mode((screen_Width_heigth))
    player_sur = screen.image.load('asset/Josh.png').convert()
    player = player_sur.get_rect(center = (17,22))
    pygame.display.set_caption('platformer: torch guy')
    game_state = [True]
    and a bunch of code that isn't gotta help you to help me

解决方法

我认为应该是 pygame.image.load 而不是 screen.image.load

Pygame Image reference

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。