主游戏.javaMouseInput.javaMenu.javaHighScoreMenu.javaEnemy.javaBufferedImageLoader.java我曾经让这段代码工作过,但我很难知道问题是什么。我试图从 a 开始joptionpane ,然后是下面创建的 gui 点击游戏。然后回到joptionpane。然后是点击游戏,这就是娱乐时搞砸的地方。它错误或通过了点击游戏。检查粘贴箱。Game game = new Game();game.setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));game.setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));game.setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));JFrame frame = new JFrame(game.TITLE);frame.add(game);frame.pack();frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setResizable(false);frame.setLocationRelativeTo(null);frame.setVisible(true);frame.setExtendedState(JFrame.MAXIMIZED_BOTH);game.start(); 我尝试将我的代码重置为默认值,尝试再次创建我想要的游戏,joptionpane但它不再起作用。看起来我的电脑不想再玩它了?我已经进行了更改,但我只是不知道是什么关闭了我的功能。@Overridepublic void run() { init(); long lastTime = System.nanoTime(); final double amountOfTicks = 60.0; double ns = 1000000000 / amountOfTicks; double delta = 0; int updates = 0; int frames = 0; long timer = System.currentTimeMillis(); while (running) { // this would be the game loop long now = System.nanoTime(); delta += (now - lastTime) / ns; lastTime = now; if (delta >= 1) { tick(); final int i = updates++; delta--; } render(); frames++; if (System.currentTimeMillis() - timer > 1000) { timer += 1000; //System.out.println(updates + " Ticks, FPS " + frames); updates = 0; frames = 0; } } stop();}private void render() { BufferStrategy bs = this.getBufferStrategy(); if (bs == null) { createBufferStrategy(2000); createBufferStrategy(2); return; }
添加回答
举报
0/150
提交
取消