#InputStream only reading certain image files as non-null within same directory. Why?
1 messages · Page 1 of 1 (latest)
The first video is an example of it running properly, showing a pallet-swapped version of the "flappy bird" image that is used unsuccessfully in the second video
The images with checkmarks work just fine, but I have no idea what makes them special, as I made them all in photoshop with the only difference being the colours
hm
heres something to try
make a new folder called res
right next to src
right click and mark it as a resources root
and move all your assets there
this might be an "intellij confused" thing and that would help it
I tried it out to no avail. The old images still work too
oh you still need the assets subfolder
so res/assets?
yeah
to match up with what it was before
if thats not the fix, show me where in the code you load flappybird.png and where you load the other stuff
I tried a couple variations of the filepath with and without the extra assets folder and it didn't work
mouseInputs = new MouseInputs(this);
importImg();
setPanelSize();
addKeyListener(new KeyboardInputs(this));
addMouseListener(mouseInputs);
addMouseMotionListener(mouseInputs);
}
private void importImg() {
InputStream is = getClass().getResourceAsStream("assets/flappybird.png");
try {
img = ImageIO.read(is);
} catch(IOException e){
e.printStackTrace();
}
}```
These are the only two methods that apply to the images
Detected code, here are some useful tools:
well good news
there doesn't seem to be anything wrong with that code
bad news
that means i don't know whats going wrong
well that's reassuringly horrifying
if you can share your code in a way i can run on my machine i can test it
I appreciate the help, I feel a little less crazy
I'm working on getting a github repo up rn
that works too
The correct location for those files by default is src/main/resources.
no they aren't using maven
Which you also happen to have, mind unfurling it?
Correct to both.
Ideally stick to one structure. Since now you have some Java files under src, and some src/main.
It worked!
Would it be worth adding the path manually just in case or should it be good as is?
Also is there anything like an upvote or rep thing I can give u guys? I appreciate the help
we should make a reputation system
it would be cool to have points
we could spend them like money