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

📄 font.java

📁 这是我们的软件课程设计,J2ME开发的手机游戏. 是一个简单的射击游戏.TXT文档在模拟器下直接运行. 我想成为会员下源码@
💻 JAVA
字号:
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;


public class Font {
	Sprite sprite;
	int width,height;
	int charhash[];
	Graphics g;

	public Font(Graphics g,Image img, int width,  int height, char[] chars) {
		this.g=g;
		sprite=new Sprite(img,width,height);
		this.width=width;
		this.height=height;
		charhash=new int[128];
		for (int i = 0; i < charhash.length; i++) {
			charhash[i]=-1;
		}
		Character c;
		for (int i = 0; i < chars.length; i++) {
			c=new Character(chars[i]);
			charhash[c.hashCode()]=i;
		}
	}

	public void drawChar(char ch, int x, int y){
		Character c=new Character(ch);
		int hashcode=c.hashCode();
		sprite.setPosition(x,y);
		if(hashcode>=0){
			sprite.setFrame(charhash[hashcode]);
			sprite.paint(g);
		}
	}

	public void drawString(String str, int x, int y){
		int length=str.length();
		for (int i = 0; i < length; i++) {
			drawChar(str.charAt(i),x+width*i,y);
		}
	}
}

⌨️ 快捷键说明

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