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

📄 scene.java

📁 自己做的HunDouLuo j2me游戏
💻 JAVA
字号:
import java.io.IOException;
import java.io.InputStream;

import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.TiledLayer;

public class Scene{
	public TiledLayer m_TLayer; 					//场景

	//构造方法
	public Scene(){
		//读取各种场景的tile图像
		try{
			Image image = Image.createImage("/demo/grid.png");
			m_TLayer = new TiledLayer( 20, 5, image, 35, 25 );
		}
		catch(IOException ioe){}
	    catch(Exception e){}
	}
	//读取地图文件
	public void LoadMap(){
		try{
			//读取地图文件
			InputStream is = getClass().getResourceAsStream("/demo/map.txt");
			int ch = -1;
			for( int nRow = 0; nRow < m_TLayer.getRows(); nRow ++ )
			{
				for( int nCol = 0; nCol < m_TLayer.getColumns(); nCol ++ )
				{
					ch = -1;
					while( ( ch < 1 || ch > 4 ) ){
						ch = is.read();
						if( ch == -1 )
							return;
						ch = ch - '0';
					}
					m_TLayer.setCell( nCol, nRow, ch );
				}
			}	
		}
		catch(IOException ioe){}
		catch(Exception e){}
	}

}

⌨️ 快捷键说明

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