当前位置: 首页>>代码示例>>Java>>正文


Java Font类代码示例

本文整理汇总了Java中org.anddev.andengine.opengl.font.Font的典型用法代码示例。如果您正苦于以下问题:Java Font类的具体用法?Java Font怎么用?Java Font使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Font类属于org.anddev.andengine.opengl.font包,在下文中一共展示了Font类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMenuScene

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
@Override
public void createMenuScene() {
	String audio = "";
	if (AndEnviroment.getInstance().getAudio())
		audio += "ON";
	else
		audio += "OFF";
	String vibro = "";
	if (AndEnviroment.getInstance().getVibro())
		vibro += "ON";
	else
		vibro += "OFF";
	Font font = GameData.getInstance().mFontGameMenu;
	
	addTextItem(MENU_AUDIO, font, "AUDIO " + audio, 1f, 0.7f, 0.7f, 1.0f, 1.0f, 1f);
	addTextItem(MENU_VIBRO, font, "VIBRO " + vibro, 1f, 0.7f, 0.7f, 1.0f, 1.0f, 1f);
	addTextItem(MENU_EXIT, font, "EXIT", 1f, 0.7f, 0.7f, 1.0f, 1.0f, 1f);
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:19,代码来源:GameMenu.java

示例2: LoadResources

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
public void LoadResources()
	{
		BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("Menu/");
		backgroundTexture = new BitmapTextureAtlas(2048, 1024, TextureOptions.REPEATING_BILINEAR_PREMULTIPLYALPHA);
		textFontTexture = new BitmapTextureAtlas(512, 512, TextureOptions.REPEATING_BILINEAR_PREMULTIPLYALPHA);

		textFont = new Font(textFontTexture, Typeface.create(Typeface.DEFAULT, Typeface.NORMAL),
			 UIConstants.TEXT_FONT_SIZE, true, Color.BLACK);

		activity.getTextureManager().loadTexture(backgroundTexture);
		activity.getTextureManager().loadTexture(textFontTexture);
		activity.getFontManager().loadFont(textFont);

		mainBackgroundRegion = BitmapTextureAtlasTextureRegionFactory
			 .createFromAsset(backgroundTexture, activity, "mymenu.png", 0, 0); //480x800
//			 .createFromAsset(backgroundTexture, activity, "mainmenu.png", 0, 0); //480x800
//			 .createFromAsset(backgroundTexture, activity, "apple.jpg", 0, 0); //480x800
		aboutBackgroundRegion = BitmapTextureAtlasTextureRegionFactory
			 .createFromAsset(backgroundTexture, activity, "about.png", 480, 0);
		buttonRegion = BitmapTextureAtlasTextureRegionFactory
			 .createFromAsset(backgroundTexture, activity, "menubutton.png", 0, 800); //221x80
	}
 
开发者ID:kotlyarovsa,项目名称:Typing-Test,代码行数:23,代码来源:MenuResMan.java

示例3: GetNormalizedText

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
public static String GetNormalizedText(Font font, String text, float textWidth) {
	// no need to normalize, its just one word, so return
	if (!text.contains(" "))
		return text;
	String[] words = text.split(" ");
	StringBuilder normalizedText = new StringBuilder();
	StringBuilder line = new StringBuilder();

	for (int i = 0; i < words.length; i++) {
		if (font.getStringWidth((line + words[i])) > (textWidth)) {
			normalizedText.append(line).append('\n');
			line = new StringBuilder();
		}

		if(line.length() == 0)
			line.append(words[i]);
		else
			line.append(' ').append(words[i]);

		if (i == words.length - 1)
			normalizedText.append(line);
	}
	return normalizedText.toString();
}
 
开发者ID:kotlyarovsa,项目名称:Typing-Test,代码行数:25,代码来源:KeyboardHelper.java

示例4: TextPopupScene

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
public TextPopupScene(final Camera pCamera, final Scene pParentScene, final Font pFont, final String pText, final float pDurationSeconds, final IEntityModifier pShapeModifier, final Runnable pRunnable) {
	super(pCamera, pParentScene, pDurationSeconds, pRunnable);

	this.mText = new Text(0, 0, pFont, pText, HorizontalAlign.CENTER);
	this.centerShapeInCamera(this.mText);

	if(pShapeModifier != null) {
		this.mText.registerEntityModifier(pShapeModifier);
	}

	this.attachChild(this.mText);
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:13,代码来源:TextPopupScene.java

示例5: updateText

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
protected void updateText(final String pText) {
	this.mText = pText;
	final Font font = this.mFont;

	this.mLines = StringUtils.split(this.mText, '\n', this.mLines);
	final String[] lines = this.mLines;

	final int lineCount = lines.length;
	final boolean widthsReusable = this.mWidths != null && this.mWidths.length == lineCount;
	if(!widthsReusable) {
		this.mWidths = new int[lineCount];
	}
	final int[] widths = this.mWidths;

	int maximumLineWidth = 0;

	for (int i = lineCount - 1; i >= 0; i--) {
		widths[i] = font.getStringWidth(lines[i]);
		maximumLineWidth = Math.max(maximumLineWidth, widths[i]);
	}
	this.mMaximumLineWidth = maximumLineWidth;

	super.mWidth = this.mMaximumLineWidth;
	final float width = super.mWidth;
	super.mBaseWidth = width;

	super.mHeight = lineCount * font.getLineHeight() + (lineCount - 1) * font.getLineGap();
	final float height = super.mHeight;
	super.mBaseHeight = height;

	this.mRotationCenterX = width * 0.5f;
	this.mRotationCenterY = height * 0.5f;

	this.mScaleCenterX = this.mRotationCenterX;
	this.mScaleCenterY = this.mRotationCenterY;

	this.mTextTextureBuffer.update(font, lines);
	this.updateVertexBuffer();
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:40,代码来源:Text.java

示例6: onUpdateVertexBuffer

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
@Override
protected void onUpdateVertexBuffer() {
	final Font font = this.mFont;
	if(font != null) {
		this.getVertexBuffer().update(font, this.mMaximumLineWidth, this.mWidths, this.mLines);
	}
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:8,代码来源:Text.java

示例7: getFont

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
public static Font getFont(final int pTextureWidth, final int pTextureHeight, final String pName, final int pSize, final int pBorderSize, final int pFillColor, final int pBorderColor) {
	Texture tex = new Texture(pTextureWidth, pTextureHeight, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
	Font font = FontFactory.createStrokeFromAsset(tex, AndEnviroment.getInstance().getContext(), "font/" + pName + ".ttf", pSize, true, pFillColor, pBorderSize, pBorderColor, false);
	AndEnviroment.getInstance().getEngine().getTextureManager().loadTexture(tex);
	AndEnviroment.getInstance().getEngine().getFontManager().loadFont(font);
	return font;
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:8,代码来源:AndResourceLoader.java

示例8: AndTextScoring

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
public AndTextScoring(final float pX, final float pY, final Font pFont, final HorizontalAlign pHorizontalAlign, final int pInitialValue, final String pLabel) {
	super(pX, pY, pFont, String.valueOf(pInitialValue), HorizontalAlign.RIGHT, 10);
	
	if (pLabel != null) {
		this.mLabel = new ChangeableText(0, 0, pFont, pLabel, 10);
		this.attachChild(this.mLabel);
	}
	
	this.mHorizontalAlign = pHorizontalAlign;
	this.mInitialValue = pInitialValue;
	this.mStartX = pX;
	this.mStartY = pY;
	
	reAlign();
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:16,代码来源:AndTextScoring.java

示例9: TextMenuItem

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
public TextMenuItem(final int pID, final Font pFont, final String pText) {
	super(0, 0, pFont, pText);
	this.mID = pID;
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:5,代码来源:TextMenuItem.java

示例10: ChangeableText

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
public ChangeableText(final float pX, final float pY, final Font pFont, final String pText) {
	this(pX, pY, pFont, pText, pText.length() - StringUtils.countOccurrences(pText, '\n'));
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:4,代码来源:ChangeableText.java

示例11: TickerText

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
public TickerText(final float pX, final float pY, final Font pFont, final String pText, final HorizontalAlign pHorizontalAlign, final float pCharactersPerSecond) {
	super(pX, pY, pFont, pText, pHorizontalAlign);
	this.setCharactersPerSecond(pCharactersPerSecond);
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:5,代码来源:TickerText.java

示例12: Text

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
public Text(final float pX, final float pY, final Font pFont, final String pText) {
	this(pX, pY, pFont, pText, HorizontalAlign.LEFT);
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:4,代码来源:Text.java

示例13: update

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
public synchronized void update(final Font font, final int pMaximumLineWidth, final int[] pWidths, final String[] pLines) {
	final int[] bufferData = this.mBufferData;
	int i = 0;

	final int lineHeight = font.getLineHeight();

	final int lineCount = pLines.length;
	for (int lineIndex = 0; lineIndex < lineCount; lineIndex++) {
		final String line = pLines[lineIndex];

		int lineX;
		switch(this.mHorizontalAlign) {
			case RIGHT:
				lineX = pMaximumLineWidth - pWidths[lineIndex];
				break;
			case CENTER:
				lineX = (pMaximumLineWidth - pWidths[lineIndex]) >> 1;
				break;
			case LEFT:
			default:
				lineX = 0;
		}

		final int lineY = lineIndex * (font.getLineHeight() + font.getLineGap());
		final int lineYBits = Float.floatToRawIntBits(lineY);

		final int lineLength = line.length();
		for (int letterIndex = 0; letterIndex < lineLength; letterIndex++) {
			final Letter letter = font.getLetter(line.charAt(letterIndex));

			final int lineY2 = lineY + lineHeight;
			final int lineX2 = lineX + letter.mWidth;

			final int lineXBits = Float.floatToRawIntBits(lineX);
			final int lineX2Bits = Float.floatToRawIntBits(lineX2);
			final int lineY2Bits = Float.floatToRawIntBits(lineY2);

			bufferData[i++] = lineXBits;
			bufferData[i++] = lineYBits;

			bufferData[i++] = lineXBits;
			bufferData[i++] = lineY2Bits;

			bufferData[i++] = lineX2Bits;
			bufferData[i++] = lineY2Bits;

			bufferData[i++] = lineX2Bits;
			bufferData[i++] = lineY2Bits;

			bufferData[i++] = lineX2Bits;
			bufferData[i++] = lineYBits;

			bufferData[i++] = lineXBits;
			bufferData[i++] = lineYBits;

			lineX += letter.mAdvance;
		}
	}

	final FastFloatBuffer vertexFloatBuffer = this.mFloatBuffer;
	vertexFloatBuffer.position(0);
	vertexFloatBuffer.put(bufferData);
	vertexFloatBuffer.position(0);

	super.setHardwareBufferNeedsUpdate();
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:67,代码来源:TextVertexBuffer.java

示例14: update

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
public synchronized void update(final Font pFont, final String[] pLines) {
	final FastFloatBuffer textureFloatBuffer = this.getFloatBuffer();
	textureFloatBuffer.position(0);

	final Font font = pFont;
	final String[] lines = pLines;

	final int lineCount = lines.length;
	for (int i = 0; i < lineCount; i++) {
		final String line = lines[i];

		final int lineLength = line.length();
		for (int j = 0; j < lineLength; j++) {
			final Letter letter = font.getLetter(line.charAt(j));

			final float letterTextureX = letter.mTextureX;
			final float letterTextureY = letter.mTextureY;
			final float letterTextureX2 = letterTextureX + letter.mTextureWidth;
			final float letterTextureY2 = letterTextureY + letter.mTextureHeight;

			textureFloatBuffer.put(letterTextureX);
			textureFloatBuffer.put(letterTextureY);

			textureFloatBuffer.put(letterTextureX);
			textureFloatBuffer.put(letterTextureY2);

			textureFloatBuffer.put(letterTextureX2);
			textureFloatBuffer.put(letterTextureY2);

			textureFloatBuffer.put(letterTextureX2);
			textureFloatBuffer.put(letterTextureY2);

			textureFloatBuffer.put(letterTextureX2);
			textureFloatBuffer.put(letterTextureY);

			textureFloatBuffer.put(letterTextureX);
			textureFloatBuffer.put(letterTextureY);
		}
	}
	textureFloatBuffer.position(0);

	this.setHardwareBufferNeedsUpdate();
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:44,代码来源:TextTextureBuffer.java

示例15: addTextItem

import org.anddev.andengine.opengl.font.Font; //导入依赖的package包/类
protected void addTextItem(final int pItemID, final Font pFont, final String pLabel, final float pSelRed, final float pSelGreen, final float pSelBlue, final float pRed, final float pGreen, final float pBlue) {
	IMenuItem resetMenuItem = new ColorMenuItemDecorator(new TextMenuItem(pItemID, pFont, pLabel), pSelRed, pSelGreen, pSelBlue, pRed, pGreen, pBlue);
	resetMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
	addMenuItem(resetMenuItem);
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:6,代码来源:AndMenuScene.java


注:本文中的org.anddev.andengine.opengl.font.Font类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。