本文整理汇总了Java中org.andengine.entity.text.Text.setX方法的典型用法代码示例。如果您正苦于以下问题:Java Text.setX方法的具体用法?Java Text.setX怎么用?Java Text.setX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.andengine.entity.text.Text
的用法示例。
在下文中一共展示了Text.setX方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SelectionStripe
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
/**
* Creates a stripe of text items.
* The distance between the items is indicated in the constructor.
* @param x X axis center of text items.
* @param y Y axis center of text items.
* @param disposition Must be DISP_HORIZONTAL or DISP_VERTICAL.
* @param itemDistance Distance between two items.
* @param itemsArray Array of string with the text elements.
* @param textAlign Alignment of the text;
* @param itemSelectedIndex Initial item selected.
*/
public SelectionStripe(float x, float y, int disposition, float itemDistance,
String[] itemsArray, int textAlign, int itemSelectedIndex) {
int numItems = itemsArray.length;
textItems = new Text[numItems];
float xItem = x;
float yItem = y;
for(int i = 0; i < numItems; i++) {
if(disposition == DISP_HORIZONTAL)
xItem = x - ((numItems - 1) / 2) * itemDistance + (i * itemDistance);
else
yItem = y + ((numItems - 1) / 2) * itemDistance - (i * itemDistance);
Text itemText = new Text(xItem, yItem,
ResourceManager.getInstance().fontMedium,
itemsArray[i],
textOps,
ResourceManager.getInstance().engine.getVertexBufferObjectManager());
if(textAlign == TEXT_ALIGN_LEFT)
itemText.setX(itemText.getX() + itemText.getWidth()/2);
if(textAlign == TEXT_ALIGN_RIGHT)
itemText.setX(itemText.getX() - itemText.getWidth()/2);
attachChild(itemText);
textItems[i] = itemText;
}
selectedItem = itemSelectedIndex;
items = itemsArray;
xPos = x;
yPos = y;
select(itemSelectedIndex, false);
}
示例2: RecordItem
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
/**
*
* @param x the x center position of record item
* @param y the y center position of record item
* @param r the record object
*/
public RecordItem(float x, float y, Record r, boolean first) {
ITextureRegion headTR = ResourceManager.getInstance().menuRecordsShoHead;
// Head:
if(r.characterId == GameManager.CHAR_SHO)
if(first)
headTR = ResourceManager.getInstance().menuRecordsShoHeadGold;
else
headTR = ResourceManager.getInstance().menuRecordsShoHead;
else if(r.characterId == GameManager.CHAR_RYOKO)
if(first)
headTR = ResourceManager.getInstance().menuRecordsRyokoHeadGold;
else
headTR = ResourceManager.getInstance().menuRecordsRyokoHead;
head = new Sprite(x - ITEM_WIDTH/2 + HEAD_WIDTH/2, y, headTR,
ResourceManager.getInstance().engine.getVertexBufferObjectManager());
attachChild(head);
// Name:
nameText = new Text(x, y,
ResourceManager.getInstance().fontSmall,
r.profileName,
new TextOptions(HorizontalAlign.CENTER),
ResourceManager.getInstance().engine.getVertexBufferObjectManager());
nameText.setX(x - ITEM_WIDTH/2 + HEAD_WIDTH + GAP + nameText.getWidth()/2);
attachChild(nameText);
// Record:
scoreText = new Text(x, y,
ResourceManager.getInstance().fontSmall,
Integer.toString(r.score),
new TextOptions(HorizontalAlign.CENTER),
ResourceManager.getInstance().engine.getVertexBufferObjectManager());
scoreText.setX(x + ITEM_WIDTH/2 - scoreText.getWidth()/2);
attachChild(scoreText);
}
示例3: show_round
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
private void show_round(int round) {
int word_index = round % this.max_rounds;
final Word challenge_word = this.random_word_list.get(word_index);
// Take the challenge word out of the list and shuffle it
List<Word> draw_words = new ArrayList<Word>(this.random_word_list);
draw_words.remove(challenge_word);
Collections.shuffle(draw_words);
// Draw max_choices-1 from the list, add the challenge word to it and shuffle again
List<Word> choice_words = draw_words.subList(0, this.max_choices-1);
choice_words.add(challenge_word);
Collections.shuffle(choice_words);
for (int i = 0; i < choice_words.size(); i++) {
final Word word = choice_words.get(i);
float available_width = (this.cardPane.getWidth()/choice_words.size());
final float wordX = i*(this.cardPane.getWidth()/choice_words.size());
final float wordY = this.cardPane.getHeight() - 150;
ITextureRegion sprite_region = this.game.wordSprites.get(word);
ButtonSprite wordSprite = new ButtonSprite(wordX+(available_width/2), wordY, sprite_region, PhoeniciaContext.vboManager, new ButtonSprite.OnClickListener() {
@Override
public void onClick(ButtonSprite buttonSprite, float v, float v1) {
if (word == challenge_word) {
pass(word, wordX);
} else {
fail(word, wordX);
}
next_round();
}
});
wordSprite.setScale(2.0f);
this.registerTouchArea(wordSprite);
this.touchAreas.add(wordSprite);
this.cardPane.attachChild(wordSprite);
}
Font wordFont = GameFonts.introText();
Text challenge_text = new Text(this.cardPane.getWidth()/2, this.cardPane.getHeight() - 300, wordFont, String.valueOf(challenge_word.chars), challenge_word.chars.length, new TextOptions(HorizontalAlign.CENTER), PhoeniciaContext.vboManager);
challenge_text.setX(this.cardPane.getWidth() / 2);
this.cardPane.attachChild(challenge_text);
}
示例4: centerText
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
private void centerText(Text text) {
text.setX((CAMERA_WIDTH / 2) - (text.getWidth() / 2));
}
示例5: rightAlignText
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
private void rightAlignText(Text text) {
text.setX(((CAMERA_WIDTH)*3)/5 - (text.getWidth() /2 ));
}
示例6: placeCenter
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
public void placeCenter(final Text pText, final Camera pCamera) {
pText.setX(pCamera.getWidth() / 2 - pText.getWidth() / 2);
}
示例7: centerText
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
private void centerText(Text text){
text.setX((MainActivity.CAMERA_WIDTH / 2) - (text.getWidth() / 2));
}