本文整理汇总了Java中org.andengine.entity.text.Text.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Text.getHeight方法的具体用法?Java Text.getHeight怎么用?Java Text.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.andengine.entity.text.Text
的用法示例。
在下文中一共展示了Text.getHeight方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: init
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
@Override
public void init(GameLevel gameLevel, PhysicsWorld physicsWorld, Engine engine) {
super.init(gameLevel, physicsWorld, engine);
float camHeight = engine.getCamera().getHeight();
float originalHeight = 1920;
float heightScale = camHeight / originalHeight;
Typeface typeFace = Typeface.createFromAsset(GoogleFlipGameApplication.sContext.getAssets(), FontFaceType.FUTURA_BOOK.getAssetName());
Font explanationFont = FontFactory.create(_engine.getFontManager(), _engine.getTextureManager(), 512, 768, TextureOptions.BILINEAR, typeFace, (int) 20 * GoogleFlipGameApplication.sContext.getResources().getDisplayMetrics().density, Color.WHITE_ABGR_PACKED_INT);
explanationFont.load();
_engine.getFontManager().loadFont(explanationFont);
Vector2 textPoint = Vector2Pool.obtain(_engine.getCamera().getWidth() / 2, _engine.getCamera().getHeight() * .70f);
String explanation1, explanation2;
switch (GoogleFlipGameApplication.getUserModel().getTutorialLevel()) {
case 1:
explanation1 = GoogleFlipGameApplication.sContext.getResources().getString(R.string.tutorial_2a);
explanation2 = GoogleFlipGameApplication.sContext.getResources().getString(R.string.tutorial_2b);
break;
case 2:
explanation1 = GoogleFlipGameApplication.sContext.getResources().getString(R.string.tutorial_3);
explanation2 = "";
break;
default:
explanation1 = GoogleFlipGameApplication.sContext.getResources().getString(R.string.tutorial_1a);
explanation2 = GoogleFlipGameApplication.sContext.getResources().getString(R.string.tutorial_1b);
break;
}
_explanationText1 = new Text(textPoint.x, textPoint.y, explanationFont, explanation1, new TextOptions(HorizontalAlign.CENTER), _engine.getVertexBufferObjectManager());
_explanationText2 = new Text(textPoint.x, textPoint.y - (_explanationText1.getHeight()), explanationFont, explanation2, new TextOptions(HorizontalAlign.CENTER), _engine.getVertexBufferObjectManager());
_engine.getScene().attachChild(_explanationText1);
_engine.getScene().attachChild(_explanationText2);
}
示例3: TextButton
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
public TextButton(List<TextButtonState> textButtonStateList, Text pText, float pX, float pY, float pAddWidth, float pAddHeight,
VertexBufferObjectManager pVertexBufferObjectManager, final OnClickListener pOnClickListener) {
super(pX, pY, pText.getWidth() + pAddWidth, pText.getHeight() + pAddHeight, pVertexBufferObjectManager);
this.setColor(Color.BLACK);
this.setAlpha(0.8f);
this.mOnClickListener = pOnClickListener;
this.mButtonText = pText;
this.mButtonText.setPosition(pAddWidth / 2, pAddHeight / 2);
attachChild(mButtonText);
this.mStateList = textButtonStateList;
this.changeState(getButtonState(State.NORMAL));
}
示例4: 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();
}
示例5: init
import org.andengine.entity.text.Text; //导入方法依赖的package包/类
private void init(KeyListenScene pBaseScene) {
// 共通ウィンドウを作成
CommonWindowRectangle comonWindowRectangle = new CommonWindowRectangle(
0,
0,
pBaseScene.getWindowWidth(),
pBaseScene.getWindowHeight(),
Color.BLACK, 0.8f,
pBaseScene);
attachChild(comonWindowRectangle);
// タイトル
float titleY = 12;
Font titleFont = pBaseScene.createFont(Typeface.DEFAULT_BOLD, 30, Color.WHITE);
Text titleText = new Text(10, 10, titleFont, "〜 経験値振り分け 〜",
pBaseScene.getBaseActivity().getVertexBufferObjectManager());
pBaseScene.placeToCenterX(titleText, titleY);
attachChild(titleText);
float titleLineY = titleText.getY() + titleText.getHeight() + 4;
Line line = new Line(10, titleLineY, pBaseScene.getWindowWidth() - 16, titleLineY,
pBaseScene.getBaseActivity().getVertexBufferObjectManager());
line.setLineWidth(1);
line.setColor(Color.WHITE);
line.setAlpha(1.0f);
attachChild(line);
TextLogic textLogic = new TextLogic();
Font defaultFont = pBaseScene.createFont(Typeface.SANS_SERIF, 16, Color.WHITE);
Font paramFont = pBaseScene.createFont(Typeface.DEFAULT, 16, Color.YELLOW);
//Font upParamFont = pBaseScene.createFont(Typeface.DEFAULT, 16, Color.BLUE);
// Expの表示
float expY = titleLineY + 4;
Rectangle totalExpTextRect = textLogic.createTextRectangle("所持経験値:", defaultFont, "100 Exp", paramFont,
pBaseScene.getBaseActivity().getVertexBufferObjectManager());
attachChild(totalExpTextRect);
Rectangle afterExpTextRect = textLogic.createTextRectangle("振り分け後経験値:", defaultFont, "0 Exp", paramFont,
pBaseScene.getBaseActivity().getVertexBufferObjectManager());
attachChild(afterExpTextRect);
totalExpTextRect.setPosition(pBaseScene.getWindowWidth() / 2 -
(totalExpTextRect.getX() + totalExpTextRect.getWidth() + 50 + afterExpTextRect.getWidth()) / 2, expY);
afterExpTextRect.setPosition(
totalExpTextRect.getX() + totalExpTextRect.getWidth() + 50,
totalExpTextRect.getY());
float expLineY = totalExpTextRect.getY() + totalExpTextRect.getHeight() + 4;
Line expLine = new Line(10, expLineY, pBaseScene.getWindowWidth() - 16, expLineY,
pBaseScene.getBaseActivity().getVertexBufferObjectManager());
expLine.setLineWidth(1);
expLine.setColor(Color.WHITE);
expLine.setAlpha(1.0f);
attachChild(expLine);
// プレイヤー情報
float playerX = 12;
float playerY = expLineY + 12;
ActorPlayerLogic actorPlayerLogic = new ActorPlayerLogic();
ActorPlayerDto actorPlayerDto = actorPlayerLogic.createActorPlayerDto(pBaseScene, 1);
PlayerStatusRectangle playerStatusRectangle = new PlayerStatusRectangle(pBaseScene, defaultFont,
actorPlayerDto, ActorSpriteUtil.getFaceFileName(actorPlayerDto.getImageResId()), playerX, playerY);
playerStatusRectangle.show(PlayerStatusRectangleType.MINI_STATUS);
attachChild(playerStatusRectangle);
}