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


Java Text.setPosition方法代码示例

本文整理汇总了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);
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:22,代码来源:LevelIntroHUD.java

示例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);
	
}
 
开发者ID:tamzi,项目名称:sophia,代码行数:20,代码来源:PriceSign.java

示例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;
}
 
开发者ID:kyokomi,项目名称:AndEngineSRPGQuest,代码行数:22,代码来源:TextLogic.java

示例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);
}
 
开发者ID:PLNech,项目名称:BactMan-Adventures,代码行数:11,代码来源:AbstractGameActivity.java

示例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);
}
 
开发者ID:PLNech,项目名称:BactMan-Adventures,代码行数:12,代码来源:AbstractGameActivity.java

示例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;
}
 
开发者ID:Callilf,项目名称:RotatingSentries,代码行数:21,代码来源:EntityFactory.java

示例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);
		}
	}
}
 
开发者ID:delight-im,项目名称:NationSoccer,代码行数:39,代码来源:BaseScene.java

示例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);
}
 
开发者ID:mmlevin,项目名称:secu3droid,代码行数:8,代码来源:GaugeDigital.java

示例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);
	
}
 
开发者ID:jjhaggar,项目名称:ninja-trials,代码行数:52,代码来源:CharacterIntroScene.java


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