org.andengine.entity.text.Text Java Examples

The following examples show how to use org.andengine.entity.text.Text. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LowMemoryTextVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpdateColor(final Text pText) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float packedColor = pText.getColor().getABGRPackedFloat();

	int bufferDataOffset = 0;
	final int charactersMaximum = pText.getCharactersMaximum();
	for(int i = 0; i < charactersMaximum; i++) {
		bufferData.put(bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
		bufferData.put(bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
		bufferData.put(bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
		bufferData.put(bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
		bufferData.put(bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
		bufferData.put(bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);

		bufferDataOffset += Text.LETTER_SIZE;
	}

	this.setDirtyOnHardware();
}
 
Example #2
Source File: LevelModeCompleteScene.java    From sopa with Apache License 2.0 6 votes vote down vote up
LevelModeCompleteScene() {

        Text levelCompleteTextShape = new Text((float) (camera.getWidth() * 0.05), (float) (camera.getHeight() * 0.05),
                resourcesManager.levelModeCompleteFont, "Level Mode\nCompleted", vbom);
        levelCompleteTextShape.setScaleCenter(0, 0);
        attachChild(levelCompleteTextShape);

        Sprite cup = new Sprite(0, 0, resourcesManager.levelModeCup, vbom);
        cup.setPosition(camera.getWidth() / 2 - cup.getWidth() / 2, camera.getHeight() * 0.4f);
        attachChild(cup);
        attachChild(new ConfettiParticleSystem(vbom, camera.getWidth()));
        setOnSceneTouchListener(new IOnSceneTouchListener() {

                @Override
                public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {

                    onBackKeyPressed();

                    return false;
                }
            });
    }
 
Example #3
Source File: JustPlayScoreScene.java    From sopa with Apache License 2.0 6 votes vote down vote up
private void addTexts(int[] currentScore) {

        Text levelCompleteTextShape = new Text((float) (camera.getWidth() * 0.12), (float) (camera.getHeight() * 0.1),
                resourcesManager.levelCompleteFont, getHeadText(), 20, vbom);
        attachChild(levelCompleteTextShape);

        Text scoreText = new Text((float) (camera.getWidth() * 0.05), (float) (camera.getHeight() * 0.45),
                resourcesManager.justPlayScoreFont, "Score:      ", vbom);
        scoreText.setColor(BLACK);
        attachChild(scoreText);

        score = new Text((float) (camera.getWidth() * 0.65), (float) (camera.getHeight() * 0.45),
                resourcesManager.justPlayScoreFont, "" + currentScore[0], 8, vbom);
        score.setColor(BLACK);
        attachChild(score);

        Text timeText = new Text((float) (camera.getWidth() * 0.05), (float) (camera.getHeight() * 0.605),
                resourcesManager.justPlayScoreFont,
                "Left Time:      \t" + justPlayResult.getLeftTime() + "\n"
                + "Extra Time:\t+" + justPlayResult.getExtraTime(), vbom);
        timeText.setColor(WHITE);
        attachChild(timeText);
    }
 
Example #4
Source File: GameScene.java    From sopa with Apache License 2.0 6 votes vote down vote up
private void addScoreText() {

        scoreText = new Text(camera.getWidth() * 0.67f, camera.getHeight() * 0.03f, resourcesManager.scoreFont,
                String.valueOf(gameService.getLevel().getMovesCount()), 4, vbom);
        attachChild(scoreText);

        Text score = new Text(camera.getWidth() * 0.67f, camera.getHeight() * 0.01f, resourcesManager.levelFont,
                "Current Moves", vbom);
        score.setScaleCenter(0, 0);
        score.setScale(0.3f);
        attachChild(score);

        Text minimumMovesScoreText = new Text(0, camera.getHeight() * 0.01f, resourcesManager.minMovesFont,
                "Min. Moves", vbom);
        minimumMovesScoreText.setScaleCenter(0, 0);
        minimumMovesScoreText.setScale(0.3f);
        attachChild(minimumMovesScoreText);

        Text minimumMovesScore = new Text(0, camera.getHeight() * 0.03f, resourcesManager.minMovesFont,
                String.valueOf(gameService.getLevel().getMinimumMovesToSolve()), vbom);
        attachChild(minimumMovesScore);
    }
 
Example #5
Source File: HighPerformanceTextVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
public void onUpdateColor(final Text pText) {
	final float[] bufferData = this.mBufferData;

	final float packedColor = pText.getColor().getABGRPackedFloat();

	int bufferDataOffset = 0;
	final int charactersMaximum = pText.getCharactersMaximum();
	for(int i = 0; i < charactersMaximum; i++) {
		bufferData[bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
		bufferData[bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
		bufferData[bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
		bufferData[bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
		bufferData[bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
		bufferData[bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;

		bufferDataOffset += Text.LETTER_SIZE;
	}

	this.setDirtyOnHardware();
}
 
Example #6
Source File: HighPerformanceTextVertexBufferObject.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdateColor(final Text pText) {
	final float[] bufferData = this.mBufferData;

	final float packedColor = pText.getColor().getABGRPackedFloat();

	int bufferDataOffset = 0;
	final int charactersMaximum = pText.getCharactersMaximum();
	for (int i = 0; i < charactersMaximum; i++) {
		bufferData[bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
		bufferData[bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
		bufferData[bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
		bufferData[bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
		bufferData[bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;
		bufferData[bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.COLOR_INDEX] = packedColor;

		bufferDataOffset += Text.LETTER_SIZE;
	}

	this.setDirtyOnHardware();
}
 
Example #7
Source File: LowMemoryTextVertexBufferObject.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onUpdateColor(final Text pText) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final float packedColor = pText.getColor().getABGRPackedFloat();

	int bufferDataOffset = 0;
	final int charactersMaximum = pText.getCharactersMaximum();
	for (int i = 0; i < charactersMaximum; i++) {
		bufferData.put(bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
		bufferData.put(bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
		bufferData.put(bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
		bufferData.put(bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
		bufferData.put(bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);
		bufferData.put(bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.COLOR_INDEX, packedColor);

		bufferDataOffset += Text.LETTER_SIZE;
	}

	this.setDirtyOnHardware();
}
 
Example #8
Source File: JustPlayLostScene.java    From sopa with Apache License 2.0 5 votes vote down vote up
private void addTexts(int[] currentScore) {

        if (isNewHighscore) {
            Text newHighscoreText = new Text((float) (camera.getWidth() * 0.12), (float) (camera.getHeight() * 0.1),
                    resourcesManager.levelCompleteFont, "       New\nHighscore", 20, vbom);
            attachChild(newHighscoreText);
        } else {
            Text levelCompleteTextShape = new Text((float) (camera.getWidth() * 0.12),
                    (float) (camera.getHeight() * 0.1), resourcesManager.levelCompleteFont, "     Game\n      Over", 20,
                    vbom);
            attachChild(levelCompleteTextShape);
            levelCompleteTextShape.setScaleCenter(levelCompleteTextShape.getWidth() / 2,
                levelCompleteTextShape.getHeight() / 2);
            levelCompleteTextShape.setScale(1.3f);
        }

        Text scoreText = new Text((float) (camera.getWidth() * 0.05), (float) (camera.getHeight() * 0.45),
                resourcesManager.justPlayScoreFont, "Score:      ", vbom);
        scoreText.setColor(BLACK);
        attachChild(scoreText);

        score = new Text((float) (camera.getWidth() * 0.6), (float) (camera.getHeight() * 0.45),
                resourcesManager.justPlayScoreFont, "" + currentScore[0], 8, vbom);
        score.setColor(BLACK);
        attachChild(score);

        Text level = new Text(scoreText.getX(), scoreText.getY() + textFieldHeight, resourcesManager.justPlayScoreFont,
                "Level:              " + justPlayResult.getLevelCount(), vbom);
        level.setColor(BLACK);
        attachChild(level);

        JustPlayScore justPlayHighscore = justPlayScoreService.getHighscore();

        if (justPlayHighscore != null) {
            Text highScore = new Text(scoreText.getX(), score.getY() + textFieldHeight * 2,
                    resourcesManager.justPlayScoreFont, "Highscore:\t" + justPlayHighscore.getPoints(), vbom);
            highScore.setColor(BLACK);
            attachChild(highScore);
        }
    }
 
Example #9
Source File: JustPlayGameScene.java    From sopa with Apache License 2.0 5 votes vote down vote up
@Override
protected void addCustomLabels() {

    leftTime = new Text(0, camera.getHeight() * 0.83f, resourcesManager.scoreFont, "", 6, vbom);
    attachChild(leftTime);

    Text leftTimeText = new Text(0, camera.getHeight() * 0.81f, resourcesManager.levelFont, "Left Time", vbom);
    leftTimeText.setScaleCenter(0, 0);
    leftTimeText.setScale(0.3f);
    attachChild(leftTimeText);
}
 
Example #10
Source File: TutorialLevelController.java    From tilt-game-android with MIT License 5 votes vote down vote up
@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);
}
 
Example #11
Source File: LevelModeGameScene.java    From sopa with Apache License 2.0 5 votes vote down vote up
@Override
protected void addCustomLabels() {

    Text levelText = new Text(0, camera.getHeight() * 0.96f, resourcesManager.levelFont, "Level", vbom);
    levelText.setScaleCenter(0, 0);
    levelText.setScale(0.3f);
    attachChild(levelText);

    Text level = new Text(0, camera.getHeight() * 0.85f, resourcesManager.levelFont,
            String.valueOf(gameService.getLevel().getId()), vbom);
    attachChild(level);
}
 
Example #12
Source File: SceneManager.java    From OpenFlappyBird with Do What The F*ck You Want To Public License 4 votes vote down vote up
private void centerText(Text text){
	text.setX((MainActivity.CAMERA_WIDTH / 2) - (text.getWidth() / 2));		
}
 
Example #13
Source File: LevelChoiceScene.java    From sopa with Apache License 2.0 4 votes vote down vote up
private void addLevelChooseTiles(final List<LevelInfo> levelInfos, float widthPerLevel) {

        for (int levelIndex = 0; levelIndex < levelInfos.size(); levelIndex++) {
            final int finalLevelIndex = levelIndex;
            ITextureRegion levelTextureRegion;
            IFont levelChoiceFont;
            final LevelInfo levelInfo = levelInfos.get(finalLevelIndex);

            if (levelInfo.isLocked()) {
                levelTextureRegion = resourcesManager.levelChoiceRegionSW;
                levelChoiceFont = resourcesManager.levelChoiceSWFont;
            } else {
                levelTextureRegion = resourcesManager.levelChoiceRegion;
                levelChoiceFont = resourcesManager.levelChoiceFont;
            }

            float levelSpriteX = getLevelSpriteX(widthPerLevel, levelIndex);
            float levelSpriteY = getLevelSpriteY(widthPerLevel, levelIndex);
            final ButtonSprite choiceLevelSprite = new ButtonSprite(levelSpriteX, levelSpriteY, levelTextureRegion,
                    vbom, new ButtonSprite.OnClickListener() {

                        @Override
                        public void onClick(ButtonSprite pButtonSprite, float pTouchAreaLocalX,
                            float pTouchAreaLocalY) {

                            if (!levelInfo.isLocked()) {
                                if (finalLevelIndex != 0) {
                                    storyService.loadGameSceneFromLevelChoiceScene(
                                        levelService.getLevelById(levelInfo.getLevelId()));
                                } else {
                                    storyService.loadTutorialSceneFromLevelChoiceScene();
                                }
                            }
                        }
                    });
            choiceLevelSprite.setWidth(widthPerLevel);
            choiceLevelSprite.setHeight(widthPerLevel);

            attachChild(choiceLevelSprite);
            registerTouchArea(choiceLevelSprite);

            int fontOffset;

            if ((levelIndex + 1) > 99) {
                fontOffset = 105;
            } else if ((levelIndex + 1) > 9) {
                fontOffset = 120;
            } else {
                fontOffset = 150;
            }

            attachChild(new Text(levelSpriteX + fontOffset, levelSpriteY + 110, levelChoiceFont,
                    String.valueOf(levelIndex + 1), vbom));

            if (!levelInfo.isLocked()) {
                ITextureRegion starOneRegion;
                ITextureRegion starTwoRegion;
                ITextureRegion starThreeRegion;

                if (levelInfo.getStars() >= 1) {
                    starOneRegion = resourcesManager.levelChoiseStarRegion;
                } else {
                    starOneRegion = resourcesManager.levelChoiseStarSWRegion;
                }

                if (levelInfo.getStars() >= 2) {
                    starTwoRegion = resourcesManager.levelChoiseStarRegion;
                } else {
                    starTwoRegion = resourcesManager.levelChoiseStarSWRegion;
                }

                if (levelInfo.getStars() >= 3) {
                    starThreeRegion = resourcesManager.levelChoiseStarRegion;
                } else {
                    starThreeRegion = resourcesManager.levelChoiseStarSWRegion;
                }

                Sprite starOne = new Sprite(levelSpriteX + 0.04f * widthPerLevel, levelSpriteY + widthPerLevel * 0.7f,
                        starOneRegion, vbom);
                Sprite starTwo = new Sprite(levelSpriteX + 0.37f * widthPerLevel, levelSpriteY + widthPerLevel * 0.65f,
                        starTwoRegion, vbom);
                Sprite starThree = new Sprite(levelSpriteX + 0.68f * widthPerLevel, levelSpriteY + widthPerLevel * 0.7f,
                        starThreeRegion, vbom);

                attachChild(starOne);
                attachChild(starTwo);
                attachChild(starThree);
            }
        }
    }
 
Example #14
Source File: HighPerformanceTextVertexBufferObject.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public void onUpdateVertices(final Text pText) {
	final float[] bufferData = this.mBufferData;

	final IFont font = pText.getFont();
	final HorizontalAlign horizontalAlign = pText.getHorizontalAlign();
	final ArrayList<CharSequence> lines = pText.getLines();
	final float lineHeight = font.getLineHeight();
	final IFloatList lineWidths = pText.getLineWidths();
	final float leading = pText.getLeading();
	final float ascent = font.getAscent();

	final float lineAlignmentWidth = pText.getLineAlignmentWidth();

	int charactersToDraw = 0;
	int bufferDataOffset = 0;

	final int lineCount = lines.size();
	for (int row = 0; row < lineCount; row++) {
		final CharSequence line = lines.get(row);

		float xBase;
		switch (horizontalAlign) {
			case RIGHT:
				xBase = lineAlignmentWidth - lineWidths.get(row);
				break;
			case CENTER:
				xBase = (lineAlignmentWidth - lineWidths.get(row)) * 0.5f;
				break;
			case LEFT:
			default:
				xBase = 0;
		}

		final float yBase = (lineCount - row) * lineHeight + ((lineCount - row - 1) * leading) + ascent;

		final int lineLength = line.length();
		Letter previousLetter = null;
		for (int i = 0; i < lineLength; i++) {
			final Letter letter = font.getLetter(line.charAt(i));
			if (previousLetter != null) {
				xBase += previousLetter.getKerning(letter.mCharacter);
			}

			if (!letter.isWhitespace()) {
				final float x = xBase + letter.mOffsetX;
				final float y = yBase - letter.mOffsetY;

				final float x2 = x + letter.mWidth;
				final float y2 = y - letter.mHeight;

				final float u = letter.mU;
				final float v = letter.mV;
				final float u2 = letter.mU2;
				final float v2 = letter.mV2;

				bufferData[bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X] = x;
				bufferData[bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y] = y2;
				bufferData[bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U] = u;
				bufferData[bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V] = v2;

				bufferData[bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X] = x;
				bufferData[bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y] = y;
				bufferData[bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U] = u;
				bufferData[bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V] = v;

				bufferData[bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X] = x2;
				bufferData[bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y] = y2;
				bufferData[bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U] = u2;
				bufferData[bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V] = v2;

				bufferData[bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X] = x2;
				bufferData[bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y] = y2;
				bufferData[bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U] = u2;
				bufferData[bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V] = v2;

				bufferData[bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X] = x;
				bufferData[bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y] = y;
				bufferData[bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U] = u;
				bufferData[bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V] = v;

				bufferData[bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X] = x2;
				bufferData[bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y] = y;
				bufferData[bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U] = u2;
				bufferData[bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V] = v;

				bufferDataOffset += Text.LETTER_SIZE;
				charactersToDraw++;
			}

			xBase += letter.mAdvance;

			previousLetter = letter;
		}
	}
	pText.setCharactersToDraw(charactersToDraw);

	this.setDirtyOnHardware();
}
 
Example #15
Source File: CreditsScene.java    From sopa with Apache License 2.0 4 votes vote down vote up
CreditsScene() {

        super();

        Text headingText = new Text(camera.getWidth() * 0.01f, camera.getHeight() * 0.01f,
                resourcesManager.creditsHeading, "Credits", vbom);
        attachChild(headingText);

        Text subHeading = new Text(camera.getWidth() * 0.03f, camera.getHeight() * 0.15f,
                resourcesManager.creditsSubHeading, "Developement", vbom);
        attachChild(subHeading);

        Text davidschilling = new Text(camera.getWidth() * 0.05f, camera.getHeight() * 0.22f,
                resourcesManager.creditsText, "David Schilling - @schillda710", vbom);
        attachChild(davidschilling);

        Text raphaelschilling = new Text(camera.getWidth() * 0.05f, camera.getHeight() * 0.25f,
                resourcesManager.creditsText, "Raphael Schilling - @ubuntius", vbom);
        attachChild(raphaelschilling);

        Text design = new Text(camera.getWidth() * 0.03f, camera.getHeight() * 0.3f, resourcesManager.creditsSubHeading,
                "Design", vbom);
        attachChild(design);

        Text raphael = new Text(camera.getWidth() * 0.05f, camera.getHeight() * 0.37f, resourcesManager.creditsText,
                "Raphael Schilling - @ubuntius", vbom);
        attachChild(raphael);

        Text libraries = new Text(camera.getWidth() * 0.03f, camera.getHeight() * 0.42f,
                resourcesManager.creditsSubHeading, "Libraries", vbom);
        attachChild(libraries);

        Text andengine = new Text(camera.getWidth() * 0.05f, camera.getHeight() * 0.49f, resourcesManager.creditsText,
                "AndEngine - andengine.org", vbom);
        attachChild(andengine);

        Text music = new Text(camera.getWidth() * 0.03f, camera.getHeight() * 0.54f, resourcesManager.creditsSubHeading,
                "Music", vbom);
        attachChild(music);

        Text menumusic = new Text(camera.getWidth() * 0.05f, camera.getHeight() * 0.61f, resourcesManager.creditsText,
                "Menu - axtoncrolley on opengameart.org", vbom);
        attachChild(menumusic);

        Text icons = new Text(camera.getWidth() * 0.03f, camera.getHeight() * 0.66f, resourcesManager.creditsSubHeading,
                "Icons", vbom);
        attachChild(icons);

        Text mute = new Text(camera.getWidth() * 0.05f, camera.getHeight() * 0.73f, resourcesManager.creditsText,
                "Mute/Unmute - mikhog on opengameart.org", vbom);
        attachChild(mute);

        Text star = new Text(camera.getWidth() * 0.05f, camera.getHeight() * 0.76f, resourcesManager.creditsText,
                "Star - Estrella Clip Art from de.clipartlogo.com", vbom);
        attachChild(star);
    }
 
Example #16
Source File: SceneManager.java    From OpenFlappyBird with Do What The F*ck You Want To Public License 4 votes vote down vote up
public Scene createScene(){

		Scene mScene = new Scene();
		VertexBufferObjectManager vbo = mContext.getVertexBufferObjectManager();

		Sprite backgroundSprite = new Sprite(0, 0 , mResourceManager.mBackgroundTextureRegion, vbo);	
		mParallaxBackground.attachParallaxEntity(new ParallaxEntity(1, backgroundSprite));

		mScene.setBackground(mParallaxBackground);
		mScene.setBackgroundEnabled(true);


		// bird		
		float birdStartXOffset = (MainActivity.CAMERA_WIDTH / 4) - (Bird.BIRD_WIDTH / 4);
		float birdYOffset = (MainActivity.CAMERA_HEIGHT / 2) - (Bird.BIRD_HEIGHT / 4);
		mBird = new Bird(birdStartXOffset, birdYOffset, mContext.getVertexBufferObjectManager(), mScene);

		//score
		mScoreText = new Text(0, 60, mResourceManager.mScoreFont, "        ", new TextOptions(HorizontalAlign.CENTER), mContext.getVertexBufferObjectManager());
		mScoreText.setZIndex(3);
		mScene.attachChild(mScoreText);		

		// get ready text
		mGetReadyText = new Text(0, 220, mResourceManager.mGetReadyFont, "Get Ready!", new TextOptions(HorizontalAlign.CENTER), mContext.getVertexBufferObjectManager());
		mGetReadyText.setZIndex(3);
		mScene.attachChild(mGetReadyText);
		centerText(mGetReadyText);

		// instructions image
		mInstructionsSprite = new Sprite(0, 0, 200, 172, mResourceManager.mInstructionsTexture, mContext.getVertexBufferObjectManager());
		mInstructionsSprite.setZIndex(3);
		mScene.attachChild(mInstructionsSprite);
		centerSprite(mInstructionsSprite);
		mInstructionsSprite.setY(mInstructionsSprite.getY() + 20);

		// copy text
		mCopyText = new Text(0, 750, mResourceManager.mCopyFont, "(c) Dean Wild 2014", new TextOptions(HorizontalAlign.CENTER), mContext.getVertexBufferObjectManager());
		mCopyText.setZIndex(3);
		mScene.attachChild(mCopyText);
		centerText(mCopyText);


		// you suck text		
		mYouSuckText = new Text(0, MainActivity.CAMERA_HEIGHT / 2 - 100, mResourceManager.mYouSuckFont, "You Suck!", new TextOptions(HorizontalAlign.CENTER), mContext.getVertexBufferObjectManager());
		mYouSuckText.setZIndex(3);		
		centerText(mYouSuckText);

		return mScene;
	}
 
Example #17
Source File: LowMemoryTextVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public void onUpdateVertices(final Text pText) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	// TODO Optimize with field access?
	final IFont font = pText.getFont();
	final ArrayList<CharSequence> lines = pText.getLines();
	final float lineHeight = font.getLineHeight();
	final IFloatList lineWidths = pText.getLineWidths();

	final float lineAlignmentWidth = pText.getLineAlignmentWidth();

	int charactersToDraw = 0;
	int bufferDataOffset = 0;

	final int lineCount = lines.size();
	for (int i = 0; i < lineCount; i++) {
		final CharSequence line = lines.get(i);

		float xBase;

		switch(pText.getHorizontalAlign()) {
			case RIGHT:
				xBase = lineAlignmentWidth - lineWidths.get(i);
				break;
			case CENTER:
				xBase = (lineAlignmentWidth - lineWidths.get(i)) * 0.5f;
				break;
			case LEFT:
			default:
				xBase = 0;
		}

		final float yBase = i * (lineHeight + pText.getLeading());

		final int lineLength = line.length();
		Letter previousLetter = null;
		for(int j = 0; j < lineLength; j++) {
			final Letter letter = font.getLetter(line.charAt(j));
			if(previousLetter != null) {
				xBase += previousLetter.getKerning(letter.mCharacter);
			}

			if(!letter.isWhitespace()) {
				final float x = xBase + letter.mOffsetX;
				final float y = yBase + letter.mOffsetY;

				final float y2 = y + letter.mHeight;
				final float x2 = x + letter.mWidth;

				final float u = letter.mU;
				final float v = letter.mV;
				final float u2 = letter.mU2;
				final float v2 = letter.mV2;

				bufferData.put(bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X, x);
				bufferData.put(bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y, y);
				bufferData.put(bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U, u);
				bufferData.put(bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V, v);

				bufferData.put(bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X, x);
				bufferData.put(bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y, y2);
				bufferData.put(bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U, u);
				bufferData.put(bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V, v2);

				bufferData.put(bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X, x2);
				bufferData.put(bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y, y2);
				bufferData.put(bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U, u2);
				bufferData.put(bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V, v2);

				bufferData.put(bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X, x2);
				bufferData.put(bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y, y2);
				bufferData.put(bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U, u2);
				bufferData.put(bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V, v2);

				bufferData.put(bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X, x2);
				bufferData.put(bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y, y);
				bufferData.put(bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U, u2);
				bufferData.put(bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V, v);

				bufferData.put(bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X, x);
				bufferData.put(bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y, y);
				bufferData.put(bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U, u);
				bufferData.put(bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V, v);

				bufferDataOffset += Text.LETTER_SIZE;
				charactersToDraw++;
			}

			xBase += letter.mAdvance;

			previousLetter = letter;
		}
	}
	pText.setCharactersToDraw(charactersToDraw);

	this.setDirtyOnHardware();
}
 
Example #18
Source File: HighPerformanceTextVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
@Override
public void onUpdateVertices(final Text pText) {
	final float[] bufferData = this.mBufferData;

	// TODO Optimize with field access?
	final IFont font = pText.getFont();
	final ArrayList<CharSequence> lines = pText.getLines();
	final float lineHeight = font.getLineHeight();
	final IFloatList lineWidths = pText.getLineWidths();

	final float lineAlignmentWidth = pText.getLineAlignmentWidth();

	int charactersToDraw = 0;
	int bufferDataOffset = 0;

	final int lineCount = lines.size();
	for (int row = 0; row < lineCount; row++) {
		final CharSequence line = lines.get(row);

		float xBase;
		switch(pText.getHorizontalAlign()) {
			case RIGHT:
				xBase = lineAlignmentWidth - lineWidths.get(row);
				break;
			case CENTER:
				xBase = (lineAlignmentWidth - lineWidths.get(row)) * 0.5f;
				break;
			case LEFT:
			default:
				xBase = 0;
		}

		final float yBase = row * (lineHeight + pText.getLeading());

		final int lineLength = line.length();
		Letter previousLetter = null;
		for(int i = 0; i < lineLength; i++) {
			final Letter letter = font.getLetter(line.charAt(i));
			if(previousLetter != null) {
				xBase += previousLetter.getKerning(letter.mCharacter);
			}

			if(!letter.isWhitespace()) {
				final float x = xBase + letter.mOffsetX;
				final float y = yBase + letter.mOffsetY;

				final float y2 = y + letter.mHeight;
				final float x2 = x + letter.mWidth;

				final float u = letter.mU;
				final float v = letter.mV;
				final float u2 = letter.mU2;
				final float v2 = letter.mV2;

				bufferData[bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X] = x;
				bufferData[bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y] = y;
				bufferData[bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U] = u;
				bufferData[bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V] = v;

				bufferData[bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X] = x;
				bufferData[bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y] = y2;
				bufferData[bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U] = u;
				bufferData[bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V] = v2;

				bufferData[bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X] = x2;
				bufferData[bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y] = y2;
				bufferData[bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U] = u2;
				bufferData[bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V] = v2;

				bufferData[bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X] = x2;
				bufferData[bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y] = y2;
				bufferData[bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U] = u2;
				bufferData[bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V] = v2;

				bufferData[bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X] = x2;
				bufferData[bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y] = y;
				bufferData[bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U] = u2;
				bufferData[bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V] = v;

				bufferData[bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X] = x;
				bufferData[bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y] = y;
				bufferData[bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U] = u;
				bufferData[bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V] = v;

				bufferDataOffset += Text.LETTER_SIZE;
				charactersToDraw++;
			}

			xBase += letter.mAdvance;

			previousLetter = letter;
		}
	}
	pText.setCharactersToDraw(charactersToDraw);

	this.setDirtyOnHardware();
}
 
Example #19
Source File: LowMemoryTextVertexBufferObject.java    From tilt-game-android with MIT License 4 votes vote down vote up
@Override
public void onUpdateVertices(final Text pText) {
	final FloatBuffer bufferData = this.mFloatBuffer;

	final IFont font = pText.getFont();
	final HorizontalAlign horizontalAlign = pText.getHorizontalAlign();
	final ArrayList<CharSequence> lines = pText.getLines();
	final float lineHeight = font.getLineHeight();
	final IFloatList lineWidths = pText.getLineWidths();
	final float leading = pText.getLeading();
	final float ascent = font.getAscent();

	final float lineAlignmentWidth = pText.getLineAlignmentWidth();

	int charactersToDraw = 0;
	int bufferDataOffset = 0;

	final int lineCount = lines.size();
	for (int row = 0; row < lineCount; row++) {
		final CharSequence line = lines.get(row);

		float xBase;

		switch (horizontalAlign) {
			case RIGHT:
				xBase = lineAlignmentWidth - lineWidths.get(row);
				break;
			case CENTER:
				xBase = (lineAlignmentWidth - lineWidths.get(row)) * 0.5f;
				break;
			case LEFT:
			default:
				xBase = 0;
		}

		final float yBase = (lineCount - row) * lineHeight + ((lineCount - row - 1) * leading) + ascent;

		final int lineLength = line.length();
		Letter previousLetter = null;
		for (int i = 0; i < lineLength; i++) {
			final Letter letter = font.getLetter(line.charAt(i));
			if (previousLetter != null) {
				xBase += previousLetter.getKerning(letter.mCharacter);
			}

			if (!letter.isWhitespace()) {
				final float x = xBase + letter.mOffsetX;
				final float y = yBase - letter.mOffsetY;

				final float x2 = x + letter.mWidth;
				final float y2 = y - letter.mHeight;

				final float u = letter.mU;
				final float v = letter.mV;
				final float u2 = letter.mU2;
				final float v2 = letter.mV2;

				bufferData.put(bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X, x);
				bufferData.put(bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y, y2);
				bufferData.put(bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U, u);
				bufferData.put(bufferDataOffset + 0 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V, v2);

				bufferData.put(bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X, x);
				bufferData.put(bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y, y);
				bufferData.put(bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U, u);
				bufferData.put(bufferDataOffset + 1 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V, v);

				bufferData.put(bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X, x2);
				bufferData.put(bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y, y2);
				bufferData.put(bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U, u2);
				bufferData.put(bufferDataOffset + 2 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V, v2);

				bufferData.put(bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X, x2);
				bufferData.put(bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y, y2);
				bufferData.put(bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U, u2);
				bufferData.put(bufferDataOffset + 3 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V, v2);

				bufferData.put(bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X, x);
				bufferData.put(bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y, y);
				bufferData.put(bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U, u);
				bufferData.put(bufferDataOffset + 4 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V, v);

				bufferData.put(bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_X, x2);
				bufferData.put(bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.VERTEX_INDEX_Y, y);
				bufferData.put(bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_U, u2);
				bufferData.put(bufferDataOffset + 5 * Text.VERTEX_SIZE + Text.TEXTURECOORDINATES_INDEX_V, v);

				bufferDataOffset += Text.LETTER_SIZE;
				charactersToDraw++;
			}

			xBase += letter.mAdvance;

			previousLetter = letter;
		}
	}
	pText.setCharactersToDraw(charactersToDraw);

	this.setDirtyOnHardware();
}
 
Example #20
Source File: ITextVertexBufferObject.java    From tilt-game-android with MIT License votes vote down vote up
public void onUpdateColor(final Text pText); 
Example #21
Source File: ITextVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 votes vote down vote up
public void onUpdateVertices(final Text pText); 
Example #22
Source File: ITextVertexBufferObject.java    From 30-android-libraries-in-30-days with Apache License 2.0 votes vote down vote up
public void onUpdateColor(final Text pText); 
Example #23
Source File: ITextVertexBufferObject.java    From tilt-game-android with MIT License votes vote down vote up
public void onUpdateVertices(final Text pText);