Eclipse CODEING help!
#1

Hey is there anyone that knows to fix a eclispse error i am trying to create a 2D Minecraft game BUT! every time i type
Quote:

screen = createVolatileImage(pixel.width, pixel.height);

or
Quote:

Graphics g = screen.getGraphics();

I get a error it dosen't say any kinda error but when i press the glowen lantorn i tried everything in there nothing helps
Reply
#2

VolatileImages are a tricky thing to use.
The frame needs to be visible and useable before you can create a volatile image, else it will return null and youll get problems.
Dont know if this would work in your case, but you could try adding a pause of about a second at the beginning of run(), before creating the image, so the frame got some time to load. There are better methods, but thats the most easy one for testing if this causes the problem.
Also, you first need to create the graphics for volatileimages, you cant just get it. Use screen.createGraphics instead of getGraphics. If its not the null problem, then this causes your errors.
Eclipse probably knows about that volatileimage load delay, so it gives you a warning.
Reply
#3

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
VolatileImages are a tricky thing to use.
The frame needs to be visible and useable before you can create a volatile image, else it will return null and youll get problems.
Dont know if this would work in your case, but you could try adding a pause of about a second at the beginning of run(), before creating the image, so the frame got some time to load. There are better methods, but thats the most easy one for testing if this causes the problem.
Eclipse probably knows about that volatileimage load delay, so it gives you a warning.
Sorry didn't understand :/ could you maybe type it in like commands
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)