本文整理汇总了Java中org.andengine.entity.text.Text类的典型用法代码示例。如果您正苦于以下问题:Java Text类的具体用法?Java Text怎么用?Java Text使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Text类属于org.andengine.entity.text包,在下文中一共展示了Text类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onUpdateColor
import org.andengine.entity.text.Text; //导入依赖的package包/类
@Override
public void onUpdateColor(final Text pText) {
final float[] bufferData = this.mBufferData;
final float packedColor = pText.getColor().getABGRPackedFloat();
int bufferDataOffset = 0;
final int charactersMaximum = pText.getCharactersMaximum();
for (int i = 0; i < charactersMaximum; i++) {
bufferData[bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
bufferDataOffset += Text.LETTER_SIZE;
}
this.setDirtyOnHardware();
}
示例2: showDeleteConfirm
import org.andengine.entity.text.Text; //导入依赖的package包/类
public void showDeleteConfirm(final SessionSprite sessionSprite) {
final Scene scene = this;
Dialog confirmDelete = new Dialog(400, 200, Dialog.Buttons.YES_NO, PhoeniciaContext.vboManager, new Dialog.DialogListener() {
@Override
public void onDialogButtonClicked(Dialog dialog, Dialog.DialogButton dialogButton) {
if (dialogButton == Dialog.DialogButton.YES) {
Debug.d("Delete session");
deleteSession(sessionSprite);
} else {
Debug.d("Don't delete session");
}
dialog.close();
scene.unregisterTouchArea(dialog);
}
});
confirmDelete.attachChild(new Text(200, 150, GameFonts.dialogText(), "Delete saved game?", 18, new TextOptions(HorizontalAlign.CENTER), PhoeniciaContext.vboManager));
scene.registerTouchArea(confirmDelete);
confirmDelete.open(scene);
}
示例3: show_sorry
import org.andengine.entity.text.Text; //导入依赖的package包/类
private void show_sorry() {
Dialog sorry_dialog = new Dialog(400, 150, Dialog.Buttons.OK, PhoeniciaContext.vboManager, new Dialog.DialogListener() {
@Override
public void onDialogButtonClicked(Dialog dialog, Dialog.DialogButton dialogButton) {
dialog.close();
unregisterTouchArea(dialog);
finish();
}
});
String counts = String.format("%1$d/%2$d", this.winnings.size(), this.max_rounds);
Text sorry_text = new Text(sorry_dialog.getWidth()/2, sorry_dialog.getHeight()-48, GameFonts.dialogText(), counts, counts.length(), new TextOptions(AutoWrap.WORDS, sorry_dialog.getWidth()*0.8f, HorizontalAlign.CENTER), PhoeniciaContext.vboManager);
sorry_text.setColor(Color.RED);
sorry_dialog.attachChild(sorry_text);
this.registerTouchArea(sorry_dialog);
sorry_dialog.open(this);
GameSounds.play(GameSounds.FAILED);
}
示例4: onInventoryUpdated
import org.andengine.entity.text.Text; //导入依赖的package包/类
/**
* Handle changes in the player's inventory by resetting the counter under each letter
* @param items The items which have changed
*/
public void onInventoryUpdated(final InventoryItem[] items) {
Debug.d("Updating WordBuilderHUD inventory");
for (int i = 0; i < items.length; i++) {
Debug.d("Updating WordBuilderHUD count for "+items[i].item_name.get());
if (this.inventoryCounts.containsKey(items[i].item_name.get())) {
Debug.d("New HUD count: "+items[i].quantity.get().toString());
final Text countText = this.inventoryCounts.get(items[i].item_name.get());
final int newCount =(items[i].quantity.get()-this.usedCounts.get(items[i].item_name.get()));
countText.setText(""+newCount);
//countText.setText("9");
} else {
Debug.e("[WordBuilderHUD] No HUD item for "+items[i].item_name.get());
}
}
}
示例5: onInventoryUpdated
import org.andengine.entity.text.Text; //导入依赖的package包/类
/**
* Handle changes in the player's inventory by resetting the counter under each letter
* @param items The items which have changed
*/
public void onInventoryUpdated(final InventoryItem[] items) {
Debug.d("Updating WorkshopHUD inventory");
for (int i = 0; i < items.length; i++) {
Debug.d("Updating WorkshopHUD count for "+items[i].item_name.get());
if (this.inventoryCounts.containsKey(items[i].item_name.get())) {
Debug.d("New HUD count: "+items[i].quantity.get().toString());
final Text countText = this.inventoryCounts.get(items[i].item_name.get());
final int newCount =(items[i].quantity.get()-this.usedCounts.get(items[i].item_name.get()));
countText.setText(""+newCount);
//countText.setText("9");
} else {
Debug.e("[Workshop] No HUD item for "+items[i].item_name.get());
}
}
}
示例6: showPage
import org.andengine.entity.text.Text; //导入依赖的package包/类
/**
* Change the display to the specified IntroPage
* @param page_index page to display
*/
private void showPage(int page_index) {
Debug.d("Showing page: "+page_index);
this.current_page = page_index;
final String nextPage = level.intro.get(page_index).text;
final TextOptions introTextOptions = new TextOptions(AutoWrap.WORDS, messageBox.getWidth()-64, HorizontalAlign.LEFT);
final Text introPageText = new Text(messageBox.getWidth()/2 - 32, messageBox.getHeight()/2, GameFonts.introText(), nextPage, introTextOptions, PhoeniciaContext.vboManager);
introPageText.setPosition(messageBox.getWidth() / 2, messageBox.getHeight() - (introPageText.getHeight() / 2));
this.messageBox.setHeight(introPageText.getHeight() + 64);
introPageText.setPosition(this.messageBox.getWidth() / 2 + 16, this.messageBox.getHeight() - (introPageText.getHeight() / 2));
messageBox.detachChildren();
messageBox.attachChild(introPageText);
messageBox.attachChild(this.nextButton);
game.playLevelSound(level.intro.get(page_index).sound, this);
}
示例7: DormidaSprite
import org.andengine.entity.text.Text; //导入依赖的package包/类
public DormidaSprite() {
super(GameActivity.WORLD_WIDTH / 2, GameActivity.WORLD_HEIGHT / 2,
ResourceManager.getInstance().NOTE_BOOK_EMPTY_TEXTURE_REGION, ResourceManager.getInstance().getVertexBuffer());
this.setY(GameActivity.WORLD_HEIGHT + this.getHeight() / 2);
float posY = 100;
winnerTitle = new Text((this.getWidth()/2)+30,this.getHeight()-posY, ResourceManager.getInstance().fontBig,"123456789",20, new TextOptions(HorizontalAlign.CENTER),ResourceManager.getInstance().getVertexBuffer());
winnerTitle.setText(ResourceManager.getInstance().context.getString(R.string.dormida));
winnerTitle.setColor(0.25490196f, 0.25490196f, 0.25490196f);
winnerTitle.setScale(0.7f);
this.attachChild(winnerTitle);
posY += 120;
winnerPlayer = new Text((this.getWidth()/2)+30,this.getHeight()-posY, ResourceManager.getInstance().fontNormal,"123456789",20, new TextOptions(HorizontalAlign.CENTER),ResourceManager.getInstance().getVertexBuffer());
this.attachChild(winnerPlayer);
this.setVisible(false);
}
示例8: onUpdateColor
import org.andengine.entity.text.Text; //导入依赖的package包/类
@Override
public void onUpdateColor(final Text pText) {
final FloatBuffer bufferData = this.mFloatBuffer;
final float packedColor = pText.getColor().getABGRPackedFloat();
int bufferDataOffset = 0;
final int charactersMaximum = pText.getCharactersMaximum();
for (int i = 0; i < charactersMaximum; i++) {
bufferData.put(bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
bufferData.put(bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
bufferData.put(bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
bufferData.put(bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
bufferData.put(bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
bufferData.put(bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
bufferDataOffset += Text.LETTER_SIZE;
}
this.setDirtyOnHardware();
}
示例9: PriceSign
import org.andengine.entity.text.Text; //导入依赖的package包/类
public PriceSign(float x, float y, float price, VertexBufferObjectManager pVertexBufferObjectManager) {
// superconstructor
super((int) x - TEXTURE.getWidth() / 2, (int) y - TEXTURE.getHeight() / 2, TEXTURE, pVertexBufferObjectManager);
// set variables
setZIndex(TowerDefense.ZINDEX_HUD);
mPrice = price;
mCenterX = (int) x;
mCenterY = (int) y;
//create text field with price
mPriceText = new Text(mCenterX, mCenterY - 5, TowerDefense.FONT_SMALL, "" + (int) mPrice, 3, getVertexBufferObjectManager());
mPriceText.setZIndex(TowerDefense.ZINDEX_HUD + 1);
mPriceText.setPosition(mCenterX - mPriceText.getWidth() / 2, mCenterY - 5);
if (TowerDefense.mSceneManager.getCurrentLevel().mCoins < mPrice) mPriceText.setColor(0.8f, 0.2f, 0.2f);
TowerDefense.mSceneManager.getCurrentLevel().attachChild(mPriceText);
}
示例10: onUpdateColor
import org.andengine.entity.text.Text; //导入依赖的package包/类
@Override
public void onUpdateColor(final Text pText) {
final float[] bufferData = this.mBufferData;
final float packedColor = pText.getColor().getABGRPackedFloat();
int bufferDataOffset = 0;
final int charactersMaximum = pText.getCharactersMaximum();
for(int i = 0; i < charactersMaximum; i++) {
bufferData[bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
bufferDataOffset += Text.LETTER_SIZE;
}
this.setDirtyOnHardware();
}
示例11: onUpdateColor
import org.andengine.entity.text.Text; //导入依赖的package包/类
@Override
public void onUpdateColor(final Text pText) {
final FloatBuffer bufferData = this.mFloatBuffer;
final float packedColor = pText.getColor().getABGRPackedFloat();
int bufferDataOffset = 0;
final int charactersMaximum = pText.getCharactersMaximum();
for(int i = 0; i < charactersMaximum; i++) {
bufferData.put(bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
bufferData.put(bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
bufferData.put(bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
bufferData.put(bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
bufferData.put(bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
bufferData.put(bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
bufferDataOffset += Text.LETTER_SIZE;
}
this.setDirtyOnHardware();
}
示例12: PowerUpComponent
import org.andengine.entity.text.Text; //导入依赖的package包/类
/**
* Constructor.
* @param timeToLive the number of seconds before the power up disappears
*/
public PowerUpComponent(PowerUpTypeEnum type, float timeToLive, Text text) {
this.timeToLive = timeToLive;
this.spawnTime = GameSingleton.getInstance().getTotalTime();
this.type = type;
this.text = text;
//Handle label of power ups : display the label if the power up is know,
//displays ???? if not.
GameSingleton singleton = GameSingleton.getInstance();
if (singleton.getKnownPowerUps().contains(type)) {
this.text.setText(type.getLabel());
} else {
this.text.setText("????");
}
}
示例13: addScoreText
import org.andengine.entity.text.Text; //导入依赖的package包/类
private void addScoreText() {
scoreText = new Text(camera.getWidth() * 0.67f, camera.getHeight() * 0.03f, resourcesManager.scoreFont,
String.valueOf(gameService.getLevel().getMovesCount()), 4, vbom);
attachChild(scoreText);
Text score = new Text(camera.getWidth() * 0.67f, camera.getHeight() * 0.01f, resourcesManager.levelFont,
"Current Moves", vbom);
score.setScaleCenter(0, 0);
score.setScale(0.3f);
attachChild(score);
Text minimumMovesScoreText = new Text(0, camera.getHeight() * 0.01f, resourcesManager.minMovesFont,
"Min. Moves", vbom);
minimumMovesScoreText.setScaleCenter(0, 0);
minimumMovesScoreText.setScale(0.3f);
attachChild(minimumMovesScoreText);
Text minimumMovesScore = new Text(0, camera.getHeight() * 0.03f, resourcesManager.minMovesFont,
String.valueOf(gameService.getLevel().getMinimumMovesToSolve()), vbom);
attachChild(minimumMovesScore);
}
示例14: addTexts
import org.andengine.entity.text.Text; //导入依赖的package包/类
private void addTexts(int[] currentScore) {
Text levelCompleteTextShape = new Text((float) (camera.getWidth() * 0.12), (float) (camera.getHeight() * 0.1),
resourcesManager.levelCompleteFont, getHeadText(), 20, vbom);
attachChild(levelCompleteTextShape);
Text scoreText = new Text((float) (camera.getWidth() * 0.05), (float) (camera.getHeight() * 0.45),
resourcesManager.justPlayScoreFont, "Score: ", vbom);
scoreText.setColor(BLACK);
attachChild(scoreText);
score = new Text((float) (camera.getWidth() * 0.65), (float) (camera.getHeight() * 0.45),
resourcesManager.justPlayScoreFont, "" + currentScore[0], 8, vbom);
score.setColor(BLACK);
attachChild(score);
Text timeText = new Text((float) (camera.getWidth() * 0.05), (float) (camera.getHeight() * 0.605),
resourcesManager.justPlayScoreFont,
"Left Time: \t" + justPlayResult.getLeftTime() + "\n"
+ "Extra Time:\t+" + justPlayResult.getExtraTime(), vbom);
timeText.setColor(WHITE);
attachChild(timeText);
}
示例15: LevelModeCompleteScene
import org.andengine.entity.text.Text; //导入依赖的package包/类
LevelModeCompleteScene() {
Text levelCompleteTextShape = new Text((float) (camera.getWidth() * 0.05), (float) (camera.getHeight() * 0.05),
resourcesManager.levelModeCompleteFont, "Level Mode\nCompleted", vbom);
levelCompleteTextShape.setScaleCenter(0, 0);
attachChild(levelCompleteTextShape);
Sprite cup = new Sprite(0, 0, resourcesManager.levelModeCup, vbom);
cup.setPosition(camera.getWidth() / 2 - cup.getWidth() / 2, camera.getHeight() * 0.4f);
attachChild(cup);
attachChild(new ConfettiParticleSystem(vbom, camera.getWidth()));
setOnSceneTouchListener(new IOnSceneTouchListener() {
@Override
public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
onBackKeyPressed();
return false;
}
});
}