How To Load Image Using Pygame.image.load()?
I just want to know the syntax. How do I load an image using pygame.image.load() ? Let's take an example, I want to load an image called cat.png - and type this pygame.image.load('
Solution 1:
By default, Python only searches in your current directory for files, however, if you wish to load images from a separate directory, you may find this useful: Importing images from a directory (Python)
For the syntax, I reccomend you refer to the documentation, here: https://www.pygame.org/docs/ref/image.html#pygame.image.load
pygame.image.load()¶
load new image from a file
load(filename) -> Surface
load(fileobj, namehint="") -> Surface
Load an image from a file source. You can pass either a filename or a Python file-like object.
Solution 2:
Any images loaded directly with
pygame.image.load('Image Name')
should be saved in the same folder as the python script that is using the image
Post a Comment for "How To Load Image Using Pygame.image.load()?"