本文整理汇总了Java中org.newdawn.slick.UnicodeFont.addAsciiGlyphs方法的典型用法代码示例。如果您正苦于以下问题:Java UnicodeFont.addAsciiGlyphs方法的具体用法?Java UnicodeFont.addAsciiGlyphs怎么用?Java UnicodeFont.addAsciiGlyphs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.newdawn.slick.UnicodeFont
的用法示例。
在下文中一共展示了UnicodeFont.addAsciiGlyphs方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: 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();
}
示例4: 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();
}
}
示例5: 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();
}
}
示例6: 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();
}
示例7: 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();
}
示例8: 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();
}
示例9: 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();
}
示例10: 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);
}
示例11: 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();
}
示例12: 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();
}
}
示例13: 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");
}
示例14: main
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
G3D.init(800, 600);
Display.setResizable(true);
setLighting();
Model m = OBJLoader.loadModel(new File("res/bunny.obj"));
int[] vbos = OBJLoader.createVBO(m);
int vboVertexHandle = vbos[0];
int vboNormalHandle = vbos[1];
glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
glVertexPointer(3, GL_FLOAT, 0, 0);
glBindBuffer(GL_ARRAY_BUFFER, vboNormalHandle);
glNormalPointer(GL_FLOAT, 0, 0);
EulerCamera cam = new EulerCamera((float)Display.getWidth() / Display.getHeight(), -2.19f, 1.36f, 11.45f);
cam.setFieldOfView(70);
cam.invertY(true);
cam.applyPerspectiveMatrix();
ShaderProgram sp = ShaderProgram.createFromResource("vbospecular.vert", "vbospecular.frag");
Font awtfont = new Font("Times New Roman", Font.BOLD, 18);
UnicodeFont font = new UnicodeFont(awtfont);
font.getEffects().add(new ColorEffect(Color.WHITE));
font.addAsciiGlyphs();
font.loadGlyphs();
G3D.loop(30, () -> {
if (Mouse.isGrabbed()) {
cam.processMouse(1, 80, -80);
}
cam.processKeyboard(16, 1, 1, 1);
if (Mouse.isButtonDown(0)) {
Mouse.setGrabbed(true);
} else if (Mouse.isButtonDown(1)) {
Mouse.setGrabbed(false);
}
G3D.setPerspective(70, 0.1f, 100);
setLighting();
cam.applyTranslations();
glLight(GL_LIGHT0, GL_POSITION, floats(cam.x(), cam.y(), cam.z(), 1));
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
sp.use();
glDrawArrays(GL_TRIANGLES, 0, m.getFaces().size() * 3);
sp.stop();
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
G2D.setOrthogonal();
glLoadIdentity();
font.drawString(10, 10, String.format("%.2f; %.2f; %.2f;", cam.x(), cam.y(), cam.z()));
glDisable(GL_TEXTURE_2D);
glColor4f(1f, 1f, 1f, 1f);
G2D.fillRect(100, 100, 100, 100);
G2D.drawRect(200, 200, 100, 100);
glEnable(GL_TEXTURE_2D);
});
}