本文整理汇总了Java中org.andengine.entity.text.Text.setText方法的典型用法代码示例。如果您正苦于以下问题:Java Text.setText方法的具体用法?Java Text.setText怎么用?Java Text.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.andengine.entity.text.Text
的用法示例。
在下文中一共展示了Text.setText方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
}
}
示例2: 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());
}
}
}
示例3: 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);
}
示例4: initFps
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
/**
* FPSの画面表示.
*/
protected void initFps(float x, float y, Font font) {
mFpsText= new Text(x, y, font, "FPS:0.000000000000000000000000",
getBaseActivity().getVertexBufferObjectManager());
mFpsText.setZIndex(999);
mFpsText.setTag(FPS_TAG);
attachChild(mFpsText);
mFpsCounter = new AverageFPSCounter(1) {
@Override
protected void onHandleAverageDurationElapsed(float pFPS) {
mFpsText.setText("FPS:" + pFPS);
}
};
registerUpdateHandler(mFpsCounter);
}
示例5: ButtonScoreSprite
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
public ButtonScoreSprite(float pX, float pY, ITiledTextureRegion pTextureRegion) {
super(pX, pY, pTextureRegion, ResourceManager.getInstance().getVertexBuffer());
text = new Text(this.getWidth()/2,this.getHeight()/2, ResourceManager.getInstance().fontBig,"123456789",10, ResourceManager.getInstance().getVertexBuffer());
text.setText("");
text.setColor(Color.BLACK);
this.attachChild(text);
}
示例6: GrowingScore
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
/**
* Create the text item and initializes the class fields.
* @param x The x position in the screen.
* @param y The y position in the screen.
* @param s Starting score (normally 0).
*/
public GrowingScore(float x, float y, int s) {
startingScore = s;
currentScore = startingScore;
scoreText = new Text(x, y,
ResourceManager.getInstance().fontMedium,
"GROWING SCORE PLACE HOLDER",
new TextOptions(HorizontalAlign.CENTER),
ResourceManager.getInstance().engine.getVertexBufferObjectManager());
scoreText.setText(Integer.toString(startingScore));
attachChild(scoreText);
setIgnoreUpdate(true);
}
示例7: updateText
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
public void updateText(Text view, String text, float x, float y, int horizontalAlign, int verticalAlign) {
if (text != null) {
view.setText(text);
}
if (horizontalAlign == TEXT_HALIGN_LEFT) {
if (verticalAlign == TEXT_VALIGN_TOP) {
view.setPosition(x+view.getWidth()/2, y-view.getHeight()/2);
}
else if (verticalAlign == TEXT_VALIGN_BOTTOM) {
view.setPosition(x+view.getWidth()/2, y+view.getHeight()/2);
}
else {
view.setPosition(x+view.getWidth()/2, y);
}
}
else if (horizontalAlign == TEXT_HALIGN_RIGHT) {
if (verticalAlign == TEXT_VALIGN_TOP) {
view.setPosition(x-view.getWidth()/2, y-view.getHeight()/2);
}
else if (verticalAlign == TEXT_VALIGN_BOTTOM) {
view.setPosition(x-view.getWidth()/2, y+view.getHeight()/2);
}
else {
view.setPosition(x-view.getWidth()/2, y);
}
}
else {
if (verticalAlign == TEXT_VALIGN_TOP) {
view.setPosition(x, y-view.getHeight()/2);
}
else if (verticalAlign == TEXT_VALIGN_BOTTOM) {
view.setPosition(x, y+view.getHeight()/2);
}
else {
view.setPosition(x, y);
}
}
}
示例8: initViews
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
public void initViews(final ResourceManager pResourceManager, final Camera pCamera) {
final float cameraHeight = pCamera.getHeight();
final float cameraWidth = pCamera.getWidth();
mRacer = new Racer(GameActivity.NUM_OF_LIVES, cameraWidth, cameraHeight, pResourceManager.mRaceCarRegion, mContext.getVertexBufferObjectManager());
mRacer.setY(cameraHeight - mRacer.getHeight() - 15f);
final int textOffsetX = (int) (cameraWidth * RACE_TRACK_WIDTH) + 20;
// scores
mHighScore = new Text(textOffsetX, 100, pResourceManager.mGameFont, "High Score\n 0123456789", new TextOptions(HorizontalAlign.LEFT), mContext.getVertexBufferObjectManager());
mHighScore.setText("High Score \n " + Persistance.getHighScore(mContext));
mScore = new Text(textOffsetX, 180, pResourceManager.mGameFont, "Score \n0123456789", mContext.getVertexBufferObjectManager());
mLives = new Text(textOffsetX, 260, pResourceManager.mGameFont, "Lives \n01234556789", mContext.getVertexBufferObjectManager());
mLives.setText("Lives \n " + mRacer.mLivesLeft);
mLevel = new Text(textOffsetX, 340, pResourceManager.mGameFont, "Level\n 0123456789", mContext.getVertexBufferObjectManager());
mScore.setText("Score \n 0");
// menus
mPlayText = new Text(cameraWidth / 2, cameraHeight / 3, pResourceManager.mGamePlayFont, "Play", 5, new TextOptions(HorizontalAlign.CENTER), mContext.getVertexBufferObjectManager());
mLevelText = new Text(cameraWidth / 2, cameraHeight / 3 + mPlayText.getHeight() + 40f, pResourceManager.mGamePlayFont, "Level", 5, new TextOptions(HorizontalAlign.CENTER),
mContext.getVertexBufferObjectManager());
mHelpText = new Text(cameraWidth / 2, cameraHeight / 3 + mLevelText.getHeight() + mPlayText.getHeight() + 80f, pResourceManager.mGamePlayFont, "Help", 4, new TextOptions(
HorizontalAlign.CENTER), mContext.getVertexBufferObjectManager());
// game over
mExplosionSprite = new Sprite(-500f, mRacer.getY(), pResourceManager.mExplosionRegion, mContext.getVertexBufferObjectManager());
mGameOverText = new Text(cameraWidth / 2, cameraHeight / 3, pResourceManager.mGamePlayFont, "Score", 5, new TextOptions(HorizontalAlign.CENTER), mContext.getVertexBufferObjectManager());
mGameOverScoreText = new Text(cameraWidth / 2, cameraHeight / 3 + mGameOverText.getHeight() + 40, pResourceManager.mGamePlayFont, " 0123456789", 12, new TextOptions(HorizontalAlign.CENTER),
mContext.getVertexBufferObjectManager());
mExplosionSprite.setCullingEnabled(true);
mExplosionSprite.setZIndex(3);
mPlayText.setAlpha(0.7f);
mHelpText.setAlpha(0.7f);
mLevelText.setAlpha(0.7f);
mGameOverText.setAlpha(0.7f);
mGameOverScoreText.setAlpha(0.7f);
mGameOverText.setColor(mGameOverTextColor);
mGameOverScoreText.setColor(mGameOverTextColor);
mPlayText.setZIndex(6);
mLevelText.setZIndex(6);
mHelpText.setZIndex(6);
mGameOverText.setZIndex(7);
mGameOverScoreText.setZIndex(7);
placeCenter(mPlayText, pCamera);
placeCenter(mHelpText, pCamera);
placeCenter(mLevelText, pCamera);
placeCenter(mGameOverText, pCamera);
placeCenter(mGameOverScoreText, pCamera);
registerTouchArea(mHelpText);
registerTouchArea(mPlayText);
registerTouchArea(mLevelText);
attachChild(mHelpText);
attachChild(mPlayText);
attachChild(mLevelText);
attachChild(mHighScore);
attachChild(mScore);
attachChild(mLives);
attachChild(mLevel);
attachChild(mRacer);
attachChild(mExplosionSprite);
sortChildren();
}
示例9: onShowScene
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
@Override
public void onShowScene() {
// Background:
// Crate the background Pattern Sprite:
ResourceManager.getInstance().mainOptionsPattern.setTextureSize(WIDTH, HEIGHT);
Sprite patternSprite = new Sprite(WIDTH/2, HEIGHT/2,
ResourceManager.getInstance().mainOptionsPattern,
ResourceManager.getInstance().engine.getVertexBufferObjectManager());
// Add pattern sprite to a new entity:
Entity backgroundEntity = new Entity();
backgroundEntity.attachChild(patternSprite);
// Create a new background from the entity ():
EntityBackground background = new EntityBackground(0.1f, 0.2f, 0.2f, backgroundEntity);
setBackground(background);
// Options tittle:
final Text tittle = new Text(WIDTH/2, HEIGHT - 150,
ResourceManager.getInstance().fontXBig, ResourceManager.getInstance().loadAndroidRes().getString(R.string.option_menu_title),
new TextOptions(HorizontalAlign.CENTER),
ResourceManager.getInstance().engine.getVertexBufferObjectManager());
attachChild(tittle);
// SelectionStripe:
selectionStripe = new SelectionStripe(250, HEIGHT / 2 - 150,
SelectionStripe.DISP_VERTICAL, 110f,
menuOptions, SelectionStripe.TEXT_ALIGN_LEFT, 0);
attachChild(selectionStripe);
// Volume Bars:
musicVolumeBar = new VolumeBar(WIDTH/2 + 600, musicPercentageYPos,
SFXManager.getMusicVolume());
attachChild(musicVolumeBar);
soundVolumeBar = new VolumeBar(WIDTH/2 + 600, soundPercentageYPos,
SFXManager.getSoundVolume());
attachChild(soundVolumeBar);
// Volume percentages:
musicPercentageText = new Text(WIDTH/2 + 200, musicPercentageYPos,
ResourceManager.getInstance().fontMedium, "10000",
new TextOptions(HorizontalAlign.CENTER),
ResourceManager.getInstance().engine.getVertexBufferObjectManager());
musicPercentageText.setText(String.valueOf(musicVolumeBar.getValuePercent()));
attachChild(musicPercentageText);
soundPercentageText = new Text(WIDTH/2 + 200, soundPercentageYPos,
ResourceManager.getInstance().fontMedium, "10000",
new TextOptions(HorizontalAlign.CENTER),
ResourceManager.getInstance().engine.getVertexBufferObjectManager());
soundPercentageText.setText(String.valueOf(soundVolumeBar.getValuePercent()));
attachChild(soundPercentageText);
}