jdf / Processing.py-Bugs

A home for all bugs and feature requests about Python Mode for the Processing Development Environment.
41 stars 8 forks source link

PImages can't be stored in class objects. #231

Closed jbox144 closed 6 years ago

jbox144 commented 6 years ago

As the title suggests, PImages can't be stored in class objects. If you're using the following code:

    def __init__(self, n, f):
        self.img = loadImage(f)
        self.name = n
    def draw(self, x, y):
        image(self.img, x * 64, y * 64)

You will get a null pointer exception. Either this is a bug, or I'm missing something horribly obvious. Please help me!

Edit: I am an idiot. You have to run the loadImage function in setup, not outside of it.