I want to get an image that is used for the background of a sprite but I don’t know how.
import pygame
pygame.init()
screen = pygame.display.set_mode(500, 500)
class Sprite(pygame.sprite.Sprite):
def __init__(self):
super(Sprite, self).__init__()
self.surf = pygame.Surface((50, 50))
self.surf = pygame.image.load("image.png").convert()
sprite = Sprite()
print(sprite.something) # ideally something that will return "image.png"
All I require is something that will return the background image of the sprite
I searched on the internet for a while and either nobody has asked this, the answer is blatantly obvious or I worded my search incorrectly. I have only tried image.surf.image
(a guess) which created an error.
geckoking is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.