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

📄 imagefont.java

📁 fishgame手机游戏 运用工具netbean可以运行起来
💻 JAVA
字号:
package cn.zucc.mmf.harpoon.util;import javax.microedition.lcdui.*;import javax.microedition.lcdui.game.*;public class ImageFont {    Sprite sprite;        int width, height;        int[] charhash;        public ImageFont(Image img, int width, int height, char[] chars) {        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(Graphics g, 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(Graphics g, String str, int x, int y) {        int length = str.length();        for (int i = 0; i < length; i++) {            drawChar(g, str.charAt(i), x + width * i, y);        }    }}

⌨️ 快捷键说明

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