本文整理汇总了Java中game.gfx.Font类的典型用法代码示例。如果您正苦于以下问题:Java Font类的具体用法?Java Font怎么用?Java Font使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Font类属于game.gfx包,在下文中一共展示了Font类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keyTyped
import game.gfx.Font; //导入依赖的package包/类
@Override
public void keyTyped(KeyEvent e) {
final TextBox t = game.getSelectedTextBox();
if (t == null) {
return;
}
if (Font.CHARS.indexOf(e.getKeyChar() + "") >= 0) {
if (t.text.length() < Constants.MESSAGE_LENGTH) {
t.text += e.getKeyChar() + "";
} else {
Toolkit.getDefaultToolkit().beep();
}
}
if (e.getKeyChar() == KeyEvent.VK_BACK_SPACE) {
if (t.text.length() > 0) {
t.text = t.text.substring(0, t.text.length() - 1);
} else {
Toolkit.getDefaultToolkit().beep();
}
}
}
示例2: keyTyped
import game.gfx.Font; //导入依赖的package包/类
@Override
public void keyTyped(KeyEvent e) {
final char c = e.getKeyChar();
if (isTyping && (c != KeyEvent.VK_BACK_SPACE)
&& (c != KeyEvent.VK_ENTER) && (c != KeyEvent.VK_ESCAPE)
&& (mode == 1)) {
if (Font.CHARS.indexOf((c + "").toUpperCase()) >= 0) {
message += c;
}
}
if (isTyping && (c != KeyEvent.VK_BACK_SPACE)
&& (c != KeyEvent.VK_ENTER) && (c != KeyEvent.VK_ESCAPE)
&& (mode == 0)) {
if (!firstChar) {
if (Font.CHARS.indexOf((c + "").toUpperCase()) >= 0) {
message += c;
}
} else {
firstChar = false;
}
}
}
示例3: render
import game.gfx.Font; //导入依赖的package包/类
/**
* Render the menu to a screen.
* @param screen {@link Screen} to render the menu to.
* @param x X position of the menu.
* @param y Y position of the menu.
*/
public void render(Screen screen, int x, int y) {
Font.render(title, screen, screen.xOffset + x, screen.yOffset + y,
Colors.get(-1, -1, -1, 550), .5);
if (input == false) {
for (int i = 0; i < options.length; i++) {
Font.render(((selected == i) ? "> " : " ") + options[i],
screen, screen.xOffset + x, screen.yOffset + y
+ ((i + 1) * 16), Colors.get(-1, -1, -1, 555),
.5);
}
} else {
for (int i = 0; i < options.length; i++) {
Font.render(((selected == i) ? "> " : " ") + options[i]
+ typedFields[i] + ((selected == i) ? "|" : " "),
screen, screen.xOffset + x, screen.yOffset + y
+ ((i + 1) * 16), Colors.get(-1, -1, -1, 555),
.5);
}
Font.render(
((selected == options.length) ? "> " : " ") + "Accept",
screen, screen.xOffset + x, screen.yOffset + y
+ (options.length * 16) + 32,
Colors.get(-1, -1, -1, 555), .5);
Font.render(((selected == (options.length + 1)) ? "> " : " ")
+ "Back", screen, screen.xOffset + x, screen.yOffset + y
+ (options.length * 16) + 48, Colors.get(-1, -1, -1, 555),
.5);
}
}
示例4: render
import game.gfx.Font; //导入依赖的package包/类
@Override
public void render(Screen screen) {
int xTile = 0;
int yTile = 2;
int walkSpeed = 4;
int flipTop = (numSteps >> walkSpeed) & 1;
int flipBottom = (numSteps >> walkSpeed) & 1;
if(movingDir == 1)
xTile += 2;
else if(movingDir > 1) {
xTile += 4 + ((numSteps >> walkSpeed) & 1) * 2;
flipTop = (movingDir - 1) % 2;
}
int modifier = TILE_SIZE * scale;
int xOffset = x - modifier / 2;
int yOffset = y - modifier / 2 - TILE_SIZE/2;
if(isSwimming) {
int[] waterColor;
yOffset += 8;
if(tickCount % 60 < 15)
waterColor = Colors.get(new int[] {-1, -1, Colors.Yellow6+Colors.Blue4, -1, -1, -1});
else if(15 <= tickCount % 60 && tickCount % 60 < 30) {
--yOffset;
waterColor = Colors.get(new int[] {-1, Colors.Yellow6+Colors.Blue4, Colors.Yellow7+Colors.Blue4, -1, -1, -1});
}
else if(30 <= tickCount % 60 && tickCount % 60 < 45)
waterColor = Colors.get(new int[] {-1, Colors.Yellow7+Colors.Blue4, -1, Colors.Yellow6+Colors.Blue4, -1, -1});
else {
--yOffset;
waterColor = Colors.get(new int[] {-1, Colors.Yellow6+Colors.Blue4, Colors.Yellow7+Colors.Blue4, -1, -1, -1});
}
screen.render(xOffset, yOffset + TILE_SIZE/2 - 1, 3, waterColor, 0x00, 1);
screen.render(xOffset + TILE_SIZE, yOffset + TILE_SIZE/2 - 1, 3, waterColor, 0x01, 1);
}
screen.render(xOffset + (modifier * flipTop), yOffset, xTile + yTile * TILES_PER_ROW, color, flipTop, scale); // upper
screen.render(xOffset + modifier - (modifier * flipTop), yOffset, (xTile + 1) + yTile * TILES_PER_ROW, color, flipTop, scale); // upper body part 2
if(!isSwimming) {
screen.render(xOffset + (modifier * flipBottom), yOffset + modifier, xTile + (yTile + 1) * TILES_PER_ROW, color, flipBottom, scale); // lower body part 1
screen.render(xOffset + modifier - (modifier * flipBottom), yOffset + modifier, (xTile + 1) + (yTile + 1) * TILES_PER_ROW, color, flipBottom, scale); // lower body part 2
}
if(cHitPoints > 0)
Font.render(String.valueOf(cHitPoints), screen, xOffset - ((TILE_SIZE/2 - 1 - String.valueOf(cHitPoints).length()%2) * (String.valueOf(cHitPoints).length() - 1) / 2), yOffset - 10*SHIFT/2,
Colors.get(new int[] {-1, Colors.Gray4, Colors.Gray3, Colors.Gray2, Colors.Gray1, Colors.White}), 1);
}
示例5: render
import game.gfx.Font; //导入依赖的package包/类
@Override
public void render(Screen screen) {
int xTile = 0;
int yTile = 2;
int walkSpeed = 4;
int flipTop = (numSteps >> walkSpeed) & 1;
int flipBottom = (numSteps >> walkSpeed) & 1;
if(movingDir == 1)
xTile += 2;
else if(movingDir > 1) {
xTile += 4 + ((numSteps >> walkSpeed) & 1) * 2;
flipTop = (movingDir - 1) % 2;
}
int modifier = TILE_SIZE * scale;
int xOffset = x - modifier / 2;
int yOffset = y - modifier / 2 - TILE_SIZE/2;
if(isSwimming) {
int[] waterColor;
yOffset += TILE_SIZE-1;
if(tickCount % 60 < 15)
waterColor = Colors.get(new int[] {-1, -1, Colors.Yellow6+Colors.Blue4, -1, -1, -1});
else if(15 <= tickCount % 60 && tickCount % 60 < 30) {
--yOffset;
waterColor = Colors.get(new int[] {-1, Colors.Yellow6+Colors.Blue4, Colors.Yellow7+Colors.Blue4, -1, -1, -1});
}
else if(30 <= tickCount % 60 && tickCount % 60 < 45)
waterColor = Colors.get(new int[] {-1, Colors.Yellow7+Colors.Blue4, -1, Colors.Yellow6+Colors.Blue4, -1, -1});
else {
--yOffset;
waterColor = Colors.get(new int[] {-1, Colors.Yellow6+Colors.Blue4, Colors.Yellow7+Colors.Blue4, -1, -1, -1});
}
screen.render(xOffset, yOffset, 3, waterColor, 0x00, 1);
screen.render(xOffset + TILE_SIZE, yOffset, 3, waterColor, 0x01, 1);
}
screen.render(xOffset + (modifier * flipTop), yOffset, xTile + yTile * TILES_PER_ROW, color, flipTop, scale); // upper
screen.render(xOffset + modifier - (modifier * flipTop), yOffset, (xTile + 1) + yTile * TILES_PER_ROW, color, flipTop, scale); // upper body part 2
if(!isSwimming) {
screen.render(xOffset + (modifier * flipBottom), yOffset + modifier, xTile + (yTile + 1) * TILES_PER_ROW, color, flipBottom, scale); // lower body part 1
screen.render(xOffset + modifier - (modifier * flipBottom), yOffset + modifier, (xTile + 1) + (yTile + 1) * TILES_PER_ROW, color, flipBottom, scale); // lower body part 2
}
if(name != null)
Font.render(name, screen, xOffset - ((TILE_SIZE/2 - 1 - name.length()%2) * (name.length() - 1) / 2), yOffset - 10*SHIFT/2,
Colors.get(new int[] {-1, Colors.Gray4, Colors.Gray3, Colors.Gray2, Colors.Gray1, Colors.White}), 1);
}
示例6: render
import game.gfx.Font; //导入依赖的package包/类
/**
* Code that is run to draw objects to the frame.
*/
private void render() {
final BufferStrategy bs = getBufferStrategy();
if (bs == null) {
createBufferStrategy(3); // Triple buffering!
return;
}
switch (stage) {
default:
case LOADING:
screen.render(0, 0, "/background.png");
loadingProgress.render(screen);
err.render(screen);
break;
case MENU:
screen.render(0, 0, "/background.png");
screen.render((Game.WIDTH / 2) - (256 / 2), 0, "/logo.png", ((int) (Math.random() * 20) > 0 ? 3
: (int) (Math.random() * 4)));
err.render(screen);
break;
case CONNECT:
screen.render(0, 0, "/background.png");
break;
case CONNECT_SETUP:
screen.render(0, 0, "/background.png");
err.render(screen);
break;
case PLAY:
screen.render(0, 0, "/background.png");
break;
case PLAY_SETUP:
screen.render(0, 0, "/background.png");
break;
case GENERAL_SETUP:
screen.render(0, 0, "/background.png");
break;
case RUNNING:
screen.render(0, 0, "/game.png");
for (final Mob m : mobs[lane]) {
if (m != null) {
m.render(screen);
}
}
if (chat != null) {
chat.render(screen);
}
Font.render(screen, (lane + 1) + "", 75, 26, 0xFFFFFFFF, false);
Font.render(screen, "Level: " + client.getLevel(), 5, 45, 0xFFFFFFFF, false);
if (client.getGold() > 9999999D) {
final NumberFormat formatter = new DecimalFormat("0E0");
formatter.setMinimumFractionDigits(6);
Font.render(screen, formatter.format(client.getGold()), 30, 4, 0xFFE5AF00, false);
} else {
Font.render(screen, (client.getGold() + "").substring(0, (client.getGold() + "").indexOf(".")), 30, 4, 0xFFE5AF00, false);
}
break;
}
for (final Button b : buttons.getAll()) {
b.render(screen);
}
for (final TextBox t : textboxes.getAll()) {
t.render();
}
for (int pix = 0; pix < screen.pixels.length; pix++) {
pixels[pix] = screen.pixels[pix];
}
final Graphics g = bs.getDrawGraphics();
g.drawImage(Game.image, 0, 0, getWidth(), getHeight(), null);
g.dispose();
bs.show();
}
示例7: render
import game.gfx.Font; //导入依赖的package包/类
/**
* Renders the credits to the screen.
* @param screen {@link Screen} to render to.
* @param start Position to render to.
* @return The height of the credits.
*/
public static int render(Screen screen, int start) {
final String[][] things = new String[][] { { "Manager", "title" },
{ "Aaron Walter", "lastperson" }, { "Assistant", "title" },
{ "Aaron Walter", "lastperson" }, { "Director", "title" },
{ "Aaron Walter", "lastperson" }, { "Code Team", "title" },
{ "Lead Programmer", "subtitle" },
{ "Aaron Walter", "person" }, { "Gameplay", "subtitle" },
{ "Aaron Walter", "person" }, { "UI", "subtitle" },
{ "Aaron Walter", "person" }, { "Controls", "subtitle" },
{ "Aaron Walter", "person" }, { "Input", "subtitle" },
{ "Aaron Walter", "lastperson" }, { "Art Team", "title" },
{ "Lead Artist", "subtitle" }, { "Aaron Walter", "person" },
{ "Level Design", "subtitle" }, { "Aaron Walter", "person" },
{ "Sprites", "subtitle" }, { "Aaron Walter", "person" },
{ "Tiles", "subtitle" }, { "Aaron Walter", "lastperson" },
{ "Networking", "title" }, { "Aaron Walter", "lastperson" },
{ "Credits", "title" }, { "Aaron Walter", "lastperson" },
{ "Misc", "title" }, { "Aaron Walter", "lastperson" },
{ "Music", "title" }, { "Kevin MacLeod", "person" },
{ "(incompetech.com)", "lastperson" },
{ "Debug Team", "title" },
{ "Since the beginning", "subtitle" },
{ "Aaron Walter", "lastperson" }, { "Since U1", "subtitle" },
{ "Kurt Bowen", "lastperson" },
{ "Since v0.0.13", "subtitle" }, { "Sam Dhuse", "person" },
{ "Kyle Stalcup", "lastperson" },
{ "Since v0.0.15", "subtitle" },
{ "Shea Hymers", "lastperson" },
{ "Since v0.0.16", "subtitle" },
{ "Ryan Pizzo", "lastperson" }, { "Thanks To", "title" },
{ "Aaron Walter", "person" }, { "Edric Yu", "person" },
{ "JLayer - javazoom.net", "person" },
{ "DesignsbyZephyr", "person" }, { "Mr. Miller", "lastperson" } };
int on = 0;
for (final String[] arr : things) {
if (arr[1].equals("title")) {
Font.render(arr[0], screen, 100, start + on,
Colors.get(-1, -1, -1, 511), 2.0);
on += 64;
} else if (arr[1].equals("subtitle")) {
Font.render(arr[0], screen, 120, start + on,
Colors.get(-1, -1, -1, 421), 1.0);
on += 32;
} else if (arr[1].equals("person")) {
Font.render(arr[0], screen, 160, start + on,
Colors.get(-1, -1, -1, 555), 1.0);
on += 32;
} else if (arr[1].equals("lastperson")) {
Font.render(arr[0], screen, 160, start + on,
Colors.get(-1, -1, -1, 555), 1.0);
on += 64;
} else {
Debug.out(Type.SEVERE, "Credits", "Could not find a type!");
}
}
return on;
}