From 49d88179e5396f7724ec5a0c803952a70b1645e0 Mon Sep 17 00:00:00 2001 From: winspeednl Date: Thu, 11 Aug 2016 20:32:48 +0200 Subject: [PATCH] Changed image type to ARGB instead of RGB. The game now requests focus (No need to click on the window anymore for focus.) --- Java/src/me/winspeednl/libz/screen/Window.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Java/src/me/winspeednl/libz/screen/Window.java b/Java/src/me/winspeednl/libz/screen/Window.java index 728a7f8..3900057 100644 --- a/Java/src/me/winspeednl/libz/screen/Window.java +++ b/Java/src/me/winspeednl/libz/screen/Window.java @@ -20,7 +20,7 @@ public class Window { private BufferStrategy bufferStrategy; public Window(GameCore gc) { - image = new BufferedImage(gc.getWidth(), gc.getHeight(), BufferedImage.TYPE_INT_RGB); + image = new BufferedImage(gc.getWidth(), gc.getHeight(), BufferedImage.TYPE_INT_ARGB); canvas = new Canvas(); Dimension size = new Dimension((int)(gc.getWidth() * gc.getScale()), (int)(gc.getHeight() * gc.getScale())); @@ -38,10 +38,14 @@ public Window(GameCore gc) { frame.setLocationRelativeTo(null); frame.setResizable(false); frame.setVisible(true); + frame.toFront(); + frame.requestFocus(); canvas.createBufferStrategy(3); bufferStrategy = canvas.getBufferStrategy(); graphics = bufferStrategy.getDrawGraphics(); + + canvas.requestFocus(); } public void update() { @@ -59,6 +63,10 @@ public void cleanup() { public Canvas getCanvas() { return canvas; } + + public JFrame getFrame() { + return frame; + } public BufferedImage getImage() { return image;