Your error messages do not have a stack trace to show where the error occurred.
Make sure your code uses printStackTrace() in the catch block. It looks like you are printing a message with no debugging information available.

Find where that message is coming from and then find out what variable is null and find out why it is null.

11-21-2011, 04:34 AM

Nonoon

Re: Calling another class to display images.

Had no idea posts had to be approved first. Boosting post counts through desperation haha |:

I have done exactly that thanks. There are no more errors but the problem still remains the same.
Could it possibly be my original menuimage covering the animation? Setting the menuimage to null when the enter key is pressed still just results in a blank white screen.

Or I have just completely misunderstood on how objects work and are created?

My first month of java!

Adding systemprints on the animation. It looks like it isn't running at all when I try to play it from the menu.

11-21-2011, 01:57 PM

Norm

Re: Calling another class to display images.

Quote:

There are no more errors but the problem still remains the same.

Quote:

Adding systemprints on the animation. It looks like it isn't running at all when I try to play it from the menu.

What do the printlns show about how your code is executing?

11-21-2011, 05:28 PM

Nonoon

Re: Calling another class to display images.

Main::start() called
Main::run() called

These two come up when the applet begins.

If I add printlns onto the play method.

Main::Play() called
Main::Play() called
Main::Play() called

Will be repeated constantly. None of the Animation class println come up unless I am running that class separately.

11-21-2011, 05:31 PM

Norm

Re: Calling another class to display images.

If that is all that you are printing out then I don't know that you are printing out enough data to tell what your code is doing.

11-21-2011, 06:36 PM

Nonoon

Re: Calling another class to display images.

Adding pintln to see if playanimation is ever set to true when pressing enter, it does so I just think I have just done things incorrectly. I think I need to do something with animation.paint() to actually draw the images again on the MainMenu.

11-21-2011, 06:41 PM

Norm

Re: Calling another class to display images.

What is the purpose of the Animation class? You create an instance of it but never call any of its methods.
Or am I looking at an older version of your code?

11-21-2011, 08:02 PM

Nonoon

Re: Calling another class to display images.

Well the Animation class is to piece together the other classes that are Character() and Background() and displays them.

I always thought once I create the new Animation(); it would call everything such as init() I'll try calling some of the methods together.

This is the current version of the code still. Should I post up the classes for Character and Background as well?

11-21-2011, 08:07 PM

Norm

Re: Calling another class to display images.

Quote:

it would call everything

Nothing will be called. If the browser had created an instance of the class, the browser would call the applet's methods.
Since you are creating the instance of the class, you are responsible for calling its methods and providing it any support that it needs.

If you want anyone to help testing your code, you need to provide all the classes it uses.

This is all the code used so far. Really appreciate the help and explanations you have given me so far.

11-21-2011, 08:57 PM

Norm

Re: Calling another class to display images.

What does the program do now when you execute it? Can you explain what you do, what the program does and what is wrong with what the program does?

11-21-2011, 09:18 PM

Nonoon

Re: Calling another class to display images.

When it starts it will display a image, when the up and arrow keys are pressed it will change the image accordingly in the array. I am trying to have it so when I am on frame 0 of the array, when the enter key is pressed it will display the images in Animation() class. However when I do press enter nothing changes.

11-21-2011, 09:25 PM

Norm

Re: Calling another class to display images.

I don't see much debugging code in the key listener. Is it being called?
The component needs focus for the key listener to work.

11-21-2011, 09:31 PM

Nonoon

Re: Calling another class to display images.

The keylistener is working since I can change between images. I added a println to check if the playgame boolean changes to true when enter key is pressed and it does.

11-21-2011, 09:33 PM

Norm

Re: Calling another class to display images.

I get a loop that you did not mention happening:
...
ArcadeGame::init() called
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/GreenCar.png
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/RedCar.png
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/BlueCar.png
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/GreenCar.png
ArcadeGame::init() called
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/GreenCar.png
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/RedCar.png
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/BlueCar.png
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/GreenCar.png
ArcadeGame::init() called
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/GreenCar.png
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/RedCar.png
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/BlueCar.png
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/GreenCar.png
ArcadeGame::init() called
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/GreenCar.png
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/RedCar.png
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/BlueCar.png
file:/D:/JavaDevelopment/Testing/ForumQuestions7/images/GreenCar.png