SA-MP Forums Archive
Eclipse CODEING help! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Other (https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: Eclipse CODEING help! (/showthread.php?tid=482195)



Eclipse CODEING help! - NukeTripper - 19.12.2013

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



Re: Eclipse CODEING help! - Mauzen - 19.12.2013

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.


Re: Eclipse CODEING help! - NukeTripper - 19.12.2013

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