本文整理汇总了Java中org.newdawn.slick.UnicodeFont.drawString方法的典型用法代码示例。如果您正苦于以下问题:Java UnicodeFont.drawString方法的具体用法?Java UnicodeFont.drawString怎么用?Java UnicodeFont.drawString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.newdawn.slick.UnicodeFont
的用法示例。
在下文中一共展示了UnicodeFont.drawString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Render
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
public void Render(int startX, int startY, UnicodeFont font) {
for (int x = 0; x < Collums; x++) {
for (int y = 0; y < Rows; y++) {
if ((y + StartRow) * Collums + x < Slots.length) {
InventoryItem i = Slots[(y + StartRow) * Collums + x]
.getItem();
if (i != null) {
i.Render(startX + x * Spacing, startY + y * Spacing);
font.drawString(
startX + x * Spacing + WidthRef,
startY + y * Spacing + WidthRef,
Integer.toString(Slots[(y + StartRow) * Collums
+ x].getAmount()), Color.black);
Color.white.bind();
}
if ((y + StartRow) * Collums + x == SelectedIcon)
RenderSelectedTexture(startX + x * Spacing, startY + y
* Spacing);
}
}
}
for (int i = 0; i < EquippedItems.length; i++) {
if (EquippedItems[i] != null) {
EquippedItems[i].Render(
startX - 230 + InvDisplayOffsets[i * 2], startY - 30
+ InvDisplayOffsets[i * 2 + 1]);
}
}
if (SelectedIcon >= 0)
if (Slots[SelectedIcon].getItem() != null)
font.drawString(startX, startY + 180, Slots[SelectedIcon]
.getItem().getName(), Color.black);
XRef = startX;
YRef = startY;
}
示例2: drawText
import org.newdawn.slick.UnicodeFont; //导入方法依赖的package包/类
/**
* Draws text with the options to scale, color, and center it.
*
* @param xLoc
* @param yLoc
* @param dScale
* @param sText
* @param color
* @param bCenterText
*/
public static void drawText(float xInput, float yInput, double dScale, String sText, boolean bCenterText)
{
//TODO: we should only accept locations as it removes some of the strange formatting when moving text
int xLoc = (int)xInput;
int yLoc = (int)yInput;
UnicodeFont unicodeFont = null;
int iFontIndex = 0;
//grab the font that is closest to the scale we are drawing.
//the font sizes are 12, 18, 24, 36, 48, 60, 72 so grab the next value up scaled from the
//standard size we specified. Then scale that font appropriately for the least aliasing.
//TODO: this can probably be done automatically by GL's texturing
for(int i = 0; i < fontSizes.length; i++)
{
if(iStandardSize * dScale * resolutionScale <= fontSizes[i])
{
unicodeFont = currentFont.get(i);
iFontIndex = i;
break;
}
}
//scale the font from the standard size using the scale the caller specifies
float fFontScale = (float) (((float)iStandardSize * dScale * resolutionScale) / fontSizes[iFontIndex] );
if(bCenterText)
{
xLoc -= unicodeFont.getWidth(sText) / 2.0 * fFontScale;
yLoc -= unicodeFont.getHeight(sText) / 2.0 * fFontScale;
}
//set up the texture to be drawn
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GL11.glEnable(GL11.GL_TEXTURE_2D);
// use bilinear interpolation to correct jagged scaling
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glEnable(GL_BLEND);
glPushMatrix();
{
glTranslated(xLoc, yLoc, 0);
//TODO: we shouldn't use gl scaling to scale textures. There's a built in texture scaling function that will do this much more cleanly.
glScaled(fFontScale, fFontScale, fFontScale);
unicodeFont.drawString(0.0f, 0.0f, sText, Theme.getThemeTextColor());
}
glPopMatrix();
glDisable(GL_BLEND);
GL11.glDisable(GL11.GL_TEXTURE_2D);
}