Reputation: 1
I am using JavaFX and Scenebuilder to create a flappybird game with an easy, hard, and normal difficulty. I made two scenes one named titlescreen and one named difficultyselectionscreen in scenebuilder. They are self explanatory. The problem is when I am on the difficultyselectionscreen when I run my App.java, it gives me and error and doesn't run my FlappyBirdEasy class code. I'm pretty sure my controller in scenebuilder is correct but there would be a ton of screenshots if I screenshotted all my code so if someone can please direct message me or comment to help me out that would be great.
I am pretty sure the problem is with my image path as that is what my catch block is saying but my path is correct I'm 99% sure. When I click the Easy button it says this after around 50 lines of errors.
InputStream birdImageStream = getClass().getResourceAsStream("/images/flappybird.png");
if (birdImageStream == null) {
System.err.println("Failed to load bird image: InputStream is null");
throw new RuntimeException("Failed to load bird image.");
} else {
System.out.println("Bird image loaded successfully");
}
It gives me the Failed to load bird message.
I tried to fix the image path multiple times but I keep getting this error.
Upvotes: -4
Views: 54
Reputation: 7
Try leaving the first line seperator away. like
InputStream birdImageStream = getClass().getResourceAsStream("images/flappybird.png");
Upvotes: -1