# load all images for the players
animation_types = ['Idle', 'Run', 'Jump']
for animation in animation_types:
# reset temporary list of images
temp_list = []
# count number of files in the folder
num_of_frames = len(os.listdir(f'Assets/{self.char_type}/{animation}'))
for i in range(num_of_frames):
img = pygame.image.load(f'Assets/{self.char_type}/{animation}/{i}.png')
img = pygame.transform.scale(img, (int(img.get_width() * scale), int(img.get_height() * scale)))
temp_list.append(img)
self.animation_list.append(temp_list)
I am fairly new to python and pygame and am making my first game. I ran into a problem where i'm trying to access files for an animation. For the idle animation the directory is Assets/player/Idle. Inside the folder are 5 images. When I run the code I receive this error:
img = pygame.image.load(f'Assets/{self.char_type}/{animation}/{i}.png')
FileNotFoundError: No such file or directory
I am pretty sure the problem is with the images in the animation folder as I made sure the other folders were found and they were fine. I honestly don't know what to do. If you need the full script then I can send it. Thank you.