⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thread.java

📁 j2me的一个手机游戏
💻 JAVA
字号:
package net.frog_parrot.jump:

/* this class contains the loop that keeps the game running.*/

public class GameThread extends Thread
{
	static boolean myShouldStop; //whether or not the main thread would like this thread to stop

	boolean myAreadyStarted;//whether or not this thread has been started

	JumpCanvas myJumpCanvas;//a handle back to the graphical components.

	
	
	//standard constructor.

	GameThread(JumpCanvas canvas)
	{
		myJumpCanvas = canvas;
	}

	//start or pause or unpause the game
	
	void go()
	{
		if(!myAlreadyStarted)
		 {
			 myAlreadyStarted = true;
		  	 start();
		  }
		else
		  {
			myShouldPause = !myShouldPause;
		  }
	}

	void pause()
	{
		myShouldPause = true;
	}

	/**
	* stops the game
	*/
	static void requestStop()
	{
		myShouldStop = true;	
	}

	/**
	* start the game
	*/
	public void run()
	{
		//flush any keystrokes that occured before the 
		//game started:
		myJumpCanvas.flushKeys();
		myShouldStop = false;
		myShouldPause = false;
		while(true)
		{
			if(myShouldStop)
			{ break ;}

			if(!myShouldPause)
			{
			   myJumpCanvas.checkKeys();
			   myJumpCanvas.advance();
			}
		}
	}	

}











⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -