# PImages change to null in separate class

**URL:** <https://discourse.processing.org/t/pimages-change-to-null-in-separate-class/8403>\
**Category:** Coding Questions\
**Created:** [February 14, 2019, 5:55pm UTC](https://discourse.processing.org/t/pimages-change-to-null-in-separate-class/8403 "2019-02-14T17:55:49Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![Kyle](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@Kyle](https://discourse.processing.org/u/Kyle)\
**Post date:** [February 20, 2019, 12:02am UTC](https://discourse.processing.org/t/pimages-change-to-null-in-separate-class/8403/9 "2019-02-20T00:02:33Z")

</div>

Thanks! I made the image work by putting a this in the bat constructor for the PApplet instead of p. However, there’s another problem, somewhat unrelated to the original problem: oddly enough, it won’t let me create object classes in the bat class. I want to create a coin by adding one to an arraylist:

```auto
coinlist.add(new coin (xlocation, ylocation, 1, elocation));

```

but it doesn’t work. There is no error or anything, it’s just that nothing happens- nothing gets added to the arraylist. (just for a little background, a coin object is one that shows a coin on screen that you can pick up). I have tried making a method in the main class that gets called in the bat class, which runs that line of code, but it still doesn’t do anything. Despite this, the coins still seem to work, because if I make a coin somewhere else in the code, it makes a coin. It just doesn’t work when it’s run from the bat class.  
What should I do to fix this problem?

---

_[View the full topic](https://discourse.processing.org/t/pimages-change-to-null-in-separate-class/8403)._
