本文整理汇总了Java中org.newdawn.slick.UnicodeFont.loadGlyphs方法的典型用法代码示例。如果您正苦于以下问题:Java UnicodeFont.loadGlyphs方法的具体用法?Java UnicodeFont.loadGlyphs怎么用?Java UnicodeFont.loadGlyphs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.newdawn.slick.UnicodeFont
的用法示例。
在下文中一共展示了UnicodeFont.loadGlyphs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFont
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void addFont(String key, String file, int size, boolean bold, boolean italic, Effect [] effects) throws SlickException {
try {
AssetManager.ASSETS_TO_LOAD++;
UnicodeFont uni = new UnicodeFont(file, size, bold, italic);
uni.addAsciiGlyphs();
uni.addGlyphs(400, 600);
uni.getEffects().add(new ColorEffect(Color.WHITE));
uni.getEffects().addAll(Arrays.asList(effects));
uni.loadGlyphs();
if((fonts != null) && (uni != null)) {
fonts.put(key, uni);
AssetManager.ASSETS_LOADED++;
System.out.println(String.format("Font Loaded: %s", key));
}
} catch(Exception ex) {
ex.printStackTrace();
System.out.printf("ERROR: Font \"%s\" could not be loaded!\n", file);
}
}
示例2: loadGlyphs
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
/**
* Adds and loads glyphs for a font.
* @param font the font to add the glyphs to
* @param s the string containing the glyphs to load
*/
public static void loadGlyphs(UnicodeFont font, String s) {
if (s == null || s.isEmpty())
return;
// get set of added strings
HashSet<String> set = loadedGlyphs.get(font);
if (set == null) {
set = new HashSet<String>();
loadedGlyphs.put(font, set);
} else if (set.contains(s))
return; // string already in set
// load glyphs
font.addGlyphs(s);
set.add(s);
try {
font.loadGlyphs();
} catch (SlickException e) {
Log.warn(String.format("Failed to load glyphs for string '%s'.", s), e);
}
}
示例3: UnicodeFontRenderer
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public UnicodeFontRenderer(Font awtFont) {
super(Minecraft.getMinecraft().gameSettings, new ResourceLocation("textures/font/ascii.png"),
Minecraft.getMinecraft().getTextureManager(), false);
font = new UnicodeFont(awtFont);
font.addAsciiGlyphs();
font.getEffects().add(new ColorEffect(Color.WHITE));
try {
font.loadGlyphs();
} catch (SlickException exception) {
throw new RuntimeException(exception);
}
String alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123456789";
FONT_HEIGHT = font.getHeight(alphabet) / 4;
}
示例4: loadFont
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
/**
* Loads a Unicode font and its ASCII glyphs.
* @param font the font to load
* @param effect the font effect
* @throws SlickException if the glyphs could not be loaded
*/
@SuppressWarnings("unchecked")
private static void loadFont(UnicodeFont font, Effect effect) throws SlickException {
font.addAsciiGlyphs();
font.getEffects().add(effect);
font.loadGlyphs();
}
示例5: loadFonts
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") //loads the fonts for the game including different font sizes.
public static void loadFonts() {
int arrayLength = GameConstants.GAME_FONT.length;
try {
for(int i = 0; i < arrayLength; i++) {
UnicodeFont font = new UnicodeFont(FONT_LOCATION, (int) ((16+10*i)/GameConstants.WINDOW_SCALE), false, false);
font.addAsciiGlyphs();
font.getEffects().add(new ColorEffect());
font.loadGlyphs();
GameConstants.GAME_FONT[i] = font;
}
} catch(Exception e) {
e.printStackTrace();
}
}
示例6: loadFonts
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
private static void loadFonts() {
font = new UnicodeFont(new java.awt.Font("Times New Roman", java.awt.Font.PLAIN, 24));
font.getEffects().add(new ColorEffect(java.awt.Color.white));
font.addAsciiGlyphs();
try { font.loadGlyphs(); }
catch (SlickException e) {
e.printStackTrace();
}
}
示例7: init
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException {
this.game = game;
Font font = new Font(Font.MONOSPACED, Font.PLAIN, 60);
ufont = new UnicodeFont(font);
ufont.addAsciiGlyphs();
ufont.addGlyphs(32, 127);
ufont.getEffects().add(new ColorEffect(Color.WHITE));
ufont.loadGlyphs();
}
示例8: entered
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
@Override
public void entered() {
java.awt.Font awtFont = new java.awt.Font("Arial", java.awt.Font.PLAIN, 24);
font = new UnicodeFont(awtFont);
font.getEffects().add(new ColorEffect(java.awt.Color.RED));
font.addAsciiGlyphs();
font.loadGlyphs();
}
示例9: initFont
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
private void initFont() {
font = new UnicodeFont(new java.awt.Font ("Vani", Font.BOLD, 12));
font.getEffects().add(new ColorEffect(java.awt.Color.white));
font.addNeheGlyphs();
try {
font.loadGlyphs();
} catch (SlickException e) {
e.printStackTrace();
}
}
示例10: loadFont
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
/**
* Loads a Unicode font and its ASCII glyphs.
* @param font the font to load
* @param effect the font effect
* @param backup the backup font
* @throws SlickException if the glyphs could not be loaded
*/
@SuppressWarnings("unchecked")
private static void loadFont(UnicodeFont font, Effect effect, UnicodeFont backup) throws SlickException {
font.addBackupFont(backup);
font.addAsciiGlyphs();
font.getEffects().add(effect);
font.loadGlyphs();
}
示例11: DamageRenderer
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
public DamageRenderer(Font font) throws SlickException {
Font f = font.deriveFont(Font.BOLD, 10);
uf = new UnicodeFont(f);
uf.getEffects().add(new ColorEffect(java.awt.Color.white));
uf.addAsciiGlyphs();
uf.loadGlyphs();
}
示例12: MainHUD
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
public MainHUD(Font font, int width) throws SlickException {
Font f = font.deriveFont(Font.BOLD, 20);
uf = new UnicodeFont(f);
uf.getEffects().add(new ColorEffect(java.awt.Color.white));
uf.addAsciiGlyphs();
uf.loadGlyphs();
hudWidth = (int) (width*0.4f);
hudPosX = (int) (width/2 - width*0.2f);
}
示例13: SimpleFont
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") //nothing we can do about this warning because it is a problem of Slick2D
public SimpleFont(Font font, Color color) throws SlickException {
ufont = new UnicodeFont(font);
ufont.getEffects().add(new ColorEffect(color));
ufont.addAsciiGlyphs();
ufont.loadGlyphs();
}
示例14: init
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
static public void init(){
font = new UnicodeFont(new Font("Times New Roman", Font.BOLD, 14));
font.addAsciiGlyphs();
font.addGlyphs(400, 600);
font.getEffects().add(new ColorEffect(java.awt.Color.WHITE)); // FIXME ?
try {
font.loadGlyphs();
} catch (SlickException e) {
e.printStackTrace();
}
}
示例15: init
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void init(GameContainer gc, StateBasedGame sbg)
throws SlickException {
errorImage = Main.loadImage("res/error2.png");
lastMouseX = gc.getInput().getAbsoluteMouseX();
lastMouseY = gc.getInput().getAbsoluteMouseY();
gc.setMouseCursor(Main.CURSOR_IMAGES.getSprite(1, 0), 16, 16);
FONT = new UnicodeFont("res/Anonymous_Pro.ttf", 12, false, false);
FONT.addAsciiGlyphs();
FONT.getEffects().add(new ColorEffect());
FONT.loadGlyphs();
coin = Main.loadImage("res/coin.png");
EditorKeyListener listener = new EditorKeyListener(this);
gc.getInput().addKeyListener(listener);
tiles = new SpriteSheet(Main.loadImage("res/tiles.png"), 32, 32);
play = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 1), 4, gc.getHeight() - 40);
play.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 1));
stop = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 2), 44, gc.getHeight() - 40);
stop.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 2));
help = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), 84, gc.getHeight() - 40);
help.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));
failed = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 3), gc.getWidth() / 2 - 16, gc.getHeight() / 2 + 40);
failed.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 3));
pause = new MouseOverArea(gc, Main.USEFUL_BUTTONS.getSprite(0, 0), 8, 8);
pause.setMouseDownImage(Main.USEFUL_BUTTONS.getSprite(1, 0));
menu = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), gc.getWidth() / 2 - 64, gc.getHeight() / 2 + 16);
menu.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));
SpriteSheet sheet = new SpriteSheet(Main.loadImage("res/tweet.png"), 128, 32);
tweet = new MouseOverArea(gc, sheet.getSprite(0, 0), gc.getWidth() / 2 - 64, gc.getHeight() / 2 + 56);
tweet.setMouseDownImage(sheet.getSprite(0, 1));
scores = new MouseOverArea(gc, Main.BIG_BUTTON.getSprite(0, 0), gc.getWidth() / 2 - 64, gc.getHeight() / 2 + 96);
scores.setMouseDownImage(Main.BIG_BUTTON.getSprite(0, 1));
coins = 0;
arrow = Main.loadImage("res/arrow.png");
}