The method gameRender() is undefined for the type GamePanel

梦想的初衷 提交于 2019-12-13 04:51:48

问题


I did everything that was correct and for some reason Eclipse thinks that the the method gameRender() is undefined for the type GamePanel:

package Game_Package;

import java.awt.Color;
import java.awt.Dimension;

import javax.swing.JPanel;

public class GamePanel extends JPanel implements Runnable{

    private static final int PWIDTH = 900;
    private static final int PHIEGHT = 900;

    private Thread animator;
    private volatile boolean running = false;

    private volatile boolean gameOver = false;

    public void gamepanel()
    {
        setBackground(Color.white);
        setPreferredSize( new Dimension(900, 900));
    }

    public void addNotify( )
    /* Wait for the JPanel to be added to the
    JFrame/JApplet before starting. */
    {
        super.addNotify( ); // creates the peer
        startGame( ); // start the thread
    }
    private void startGame( )
    // initialise and start the thread
    {
        if (animator == null || !running) {
            animator = new Thread(this);
            animator.start( );
        }
    }
    public void stopGame( )
    // called by the user to stop execution
    { 
        running = false;
    }

    public void run( )
    /* Repeatedly update, render, sleep */
    {
        running = true;
        while(running) {
            gameUpdate( ); // game state is updated
            gameRender( ); // render to a buffer
            repaint( ); // paint with the buffer
            try {
                Thread.sleep(20); // sleep a bit
            }
            catch(InterruptedException ex){

            }
        }
        System.exit(0); // so enclosing JFrame/JApplet exits
    }

    private void gameUpdate( )
    {
        if (!gameOver);
    }
}

来源:https://stackoverflow.com/questions/20111392/the-method-gamerender-is-undefined-for-the-type-gamepanel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!