本文整理汇总了Java中org.andengine.entity.text.Text.setPosition方法的典型用法代码示例。如果您正苦于以下问题:Java Text.setPosition方法的具体用法?Java Text.setPosition怎么用?Java Text.setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.andengine.entity.text.Text
的用法示例。
在下文中一共展示了Text.setPosition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: createTextRectangle
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
public Rectangle createTextRectangle(String titleStr, Font titleFont, String detatilStr, Font detailFont,
VertexBufferObjectManager pVertexBufferObjectManager) {
Text titleText = new Text(0, 0, titleFont, titleStr,
pVertexBufferObjectManager);
Text detatilText = new Text(0, 0, detailFont, detatilStr,
pVertexBufferObjectManager);
titleText.setPosition(0, 0);
detatilText.setPosition(titleText.getX() + titleText.getWidth(), titleText.getY());
float textWidth = titleText.getWidth() + detatilText.getWidth();
float textHeight = titleText.getHeight();
Rectangle resultRectangle = new Rectangle(0, 0, textWidth, textHeight,
pVertexBufferObjectManager);
resultRectangle.setColor(Color.TRANSPARENT);
resultRectangle.setAlpha(0.0f);
resultRectangle.attachChild(titleText);
resultRectangle.attachChild(detatilText);
return resultRectangle;
}
示例4: onLose
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
public void onLose(int score, float posRatioX, float posRatioY) {
music.pause();
final IFont menuFont = getFont(FontAsset.name(ResMan.F_HUD_BIN, ResMan.F_HUD_BIN_SIZE, ResMan.F_HUD_BIN_COLOR, ResMan.F_HUD_BIN_ANTI));
gameOverText = new Text(0, 0, menuFont, getEndTextAndUpdateHighScore(false, score), 32, new TextOptions(HorizontalAlign.CENTER), getVBOM());
final Vector2 textPosition = spritePosition(gameOverText.getWidth(), gameOverText.getHeight(), posRatioX, posRatioY);
gameOverText.setPosition(textPosition.x, textPosition.y);
pauseScene.attachChild(gameOverText);
currentGame.logLevelEnd(score, false);
gameScene.setChildScene(pauseScene, false, true, true);
}
示例5: onWin
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
public void onWin(int score, float posRatioX, float posRatioY) {
music.pause();
final IFont menuFont = getFont(FontAsset.name(ResMan.F_HUD_BIN, ResMan.F_HUD_BIN_SIZE, ResMan.F_HUD_BIN_COLOR, ResMan.F_HUD_BIN_ANTI));
winText = new Text(0, 0, menuFont, getEndTextAndUpdateHighScore(true, score), 32, new TextOptions(HorizontalAlign.CENTER), getVBOM());
final Vector2 textPosition = spritePosition(winText.getWidth(), winText.getHeight(), posRatioX, posRatioY);
winText.setPosition(textPosition.x, textPosition.y);
winScene.attachChild(winText);
updateNextGame();
currentGame.logLevelEnd(score, true);
gameScene.setChildScene(winScene, false, true, true);
}
示例6: generatePowerUp
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
/**
* Generate a power up that can be collected by shooting it.
* @param x the x pos
* @param y the y pos
* @return the generated power up
*/
public Entity generatePowerUp(float centerX, float centerY, PowerUpTypeEnum type) {
final Sprite sPowerUp = new Sprite(0, 0, spriteLoader.getPowerUpTextureRegion(), this.vertextBufferObjectManager);
sPowerUp.setZIndex(9);
SpriteUtil.setCenter(sPowerUp, centerX, centerY);
Entity powerUp = this.em.createEntity();
this.em.addComponentToEntity(new SpriteComponent(sPowerUp, false), powerUp);
Text puText = new Text(0, 0, spriteLoader.getPowerUpFont(), "azertyuiop azertyuiop azertyuiop", new TextOptions(AutoWrap.WORDS, 74, HorizontalAlign.CENTER), this.vertextBufferObjectManager);
puText.setPosition(43 - puText.getWidth()/2f, 43 - puText.getHeight()/2f);
sPowerUp.attachChild(puText);
this.em.addComponentToEntity(new PowerUpComponent(type, 4, puText), powerUp);
return powerUp;
}
示例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: attach
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
@Override
public void attach(Scene scene, VertexBufferObjectManager vertexBufferObjectManager) {
text = new Text (getX(),getY(),font,String.format(format, value),15,new TextOptions(HorizontalAlign.LEFT),vertexBufferObjectManager);
text.setAnchorCenterX(0);
text.setPosition(getX()-text.getWidth()/2, getY());
scene.attachChild(text);
}
示例9: Character
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
public Character() {
ITextureRegion characterITR;
if (character == "Ryoko") {
characterITR = ResourceManager.getInstance().characterProfileRyoko;
name = ResourceManager.getInstance().loadAndroidRes().getString(R.string.profile_ryoko_name);
name_jp = ResourceManager.getInstance().loadAndroidRes().getString(R.string.profile_ryoko_name_jap);
info = ResourceManager.getInstance().loadAndroidRes().getString(R.string.profile_ryoko_info);
}
else {
characterITR = ResourceManager.getInstance().characterProfileSho;
name = ResourceManager.getInstance().loadAndroidRes().getString(R.string.profile_sho_name);
name_jp = ResourceManager.getInstance().loadAndroidRes().getString(R.string.profile_sho_name_jap);
info = ResourceManager.getInstance().loadAndroidRes().getString(R.string.profile_sho_info);
}
sprite = new Sprite(spritePosX, spritePosY, characterITR, ResourceManager.getInstance().engine.getVertexBufferObjectManager());
sprite.setScale(spriteScaleAdjustment);
attachChild(sprite);
nameT = new Text(
SCRNWIDTH * 0.5f,
SCRNHEIGHT * 0.5f,
ResourceManager.getInstance().fontLatinChrName, name,
new TextOptions(HorizontalAlign.CENTER),
ResourceManager.getInstance().engine
.getVertexBufferObjectManager());
nameT.setPosition(namePosX, namePosY);
attachChild(nameT);
name_jpT = new Text(
SCRNWIDTH * 0.5f,
SCRNHEIGHT * 0.5f,
ResourceManager.getInstance().fontJPChrName, name_jp,
new TextOptions(HorizontalAlign.CENTER),
ResourceManager.getInstance().engine
.getVertexBufferObjectManager());
name_jpT.setPosition(name_jpPosX, name_jpPosY);
attachChild(name_jpT);
infoT = new Text(
SCRNWIDTH * 0.5f,
SCRNHEIGHT * 0.5f,
ResourceManager.getInstance().fontLatinChrInfo, info,
new TextOptions(HorizontalAlign.LEFT),
ResourceManager.getInstance().engine
.getVertexBufferObjectManager());
infoT.setPosition(infoPosX, infoPosY);
attachChild(infoT);
}