org.andengine.opengl.font.FontFactory Java Examples

The following examples show how to use org.andengine.opengl.font.FontFactory. 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: 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 #2
Source File: ResourceLoader.java    From sopa with Apache License 2.0 5 votes vote down vote up
IFont getFont(final String name, float size, int color, float strokeWidth, int strokeColor) {

        FontFactory.setAssetBasePath("fonts/");

        final ITexture mainFontTexture = new BitmapTextureAtlas(textureManager, 1024, 1024, TextureOptions.BILINEAR);
        IFont font = FontFactory.createStrokeFromAsset(fontManager, mainFontTexture, assetManager, name, size, true,
                color, strokeWidth, strokeColor);
        font.load();

        return font;
    }
 
Example #3
Source File: Engine.java    From tilt-game-android with MIT License 4 votes vote down vote up
public Engine(final EngineOptions pEngineOptions) {
	/* Initialize Factory and Manager classes. */
	BitmapTextureAtlasTextureRegionFactory.reset();
	SoundFactory.onCreate();
	MusicFactory.onCreate();
	FontFactory.onCreate();
	this.mVertexBufferObjectManager.onCreate();
	this.mTextureManager.onCreate();
	this.mFontManager.onCreate();
	this.mShaderProgramManager.onCreate();

	/* Apply EngineOptions. */
	this.mEngineOptions = pEngineOptions;
	if (this.mEngineOptions.hasEngineLock()) {
		this.mEngineLock = pEngineOptions.getEngineLock();
	} else {
		this.mEngineLock = new EngineLock(false);
	}
	this.mCamera = pEngineOptions.getCamera();

	/* Touch. */
	if (this.mEngineOptions.getTouchOptions().needsMultiTouch()) {
		this.setTouchController(new MultiTouchController());
	} else {
		this.setTouchController(new SingleTouchController());
	}

	/* Audio. */
	if (this.mEngineOptions.getAudioOptions().needsSound()) {
		this.mSoundManager = new SoundManager(this.mEngineOptions.getAudioOptions().getSoundOptions().getMaxSimultaneousStreams());
	} else {
		this.mSoundManager = null;
	}
	if (this.mEngineOptions.getAudioOptions().needsMusic()) {
		this.mMusicManager = new MusicManager();
	} else {
		this.mMusicManager = null;
	}

	/* Start the UpdateThread. */
	if (this.mEngineOptions.hasUpdateThread()) {
		this.mUpdateThread = this.mEngineOptions.getUpdateThread();
	} else {
		this.mUpdateThread = new UpdateThread();
	}
	this.mUpdateThread.setEngine(this);
}
 
Example #4
Source File: Engine.java    From 30-android-libraries-in-30-days with Apache License 2.0 4 votes vote down vote up
public Engine(final EngineOptions pEngineOptions) {
	/* Initialize Factory and Manager classes. */
	BitmapTextureAtlasTextureRegionFactory.reset();
	SoundFactory.onCreate();
	MusicFactory.onCreate();
	FontFactory.onCreate();
	this.mVertexBufferObjectManager.onCreate();
	this.mTextureManager.onCreate();
	this.mFontManager.onCreate();
	this.mShaderProgramManager.onCreate();

	/* Apply EngineOptions. */
	this.mEngineOptions = pEngineOptions;
	if(this.mEngineOptions.hasEngineLock()) {
		this.mEngineLock = pEngineOptions.getEngineLock();
	} else {
		this.mEngineLock = new EngineLock(false);
	}
	this.mCamera = pEngineOptions.getCamera();

	/* Touch. */
	if(this.mEngineOptions.getTouchOptions().needsMultiTouch()) {
		this.setTouchController(new MultiTouchController());
	} else {
		this.setTouchController(new SingleTouchController());
	}

	/* Audio. */
	if(this.mEngineOptions.getAudioOptions().needsSound()) {
		this.mSoundManager = new SoundManager(this.mEngineOptions.getAudioOptions().getSoundOptions().getMaxSimultaneousStreams());
	} else {
		this.mSoundManager = null;
	}
	if(this.mEngineOptions.getAudioOptions().needsMusic()) {
		this.mMusicManager = new MusicManager();
	} else {
		this.mMusicManager = null;
	}

	/* Start the UpdateThread. */
	if(this.mEngineOptions.hasUpdateThread()) {
		this.mUpdateThread = this.mEngineOptions.getUpdateThread();
	} else {
		this.mUpdateThread = new UpdateThread();
	}
	this.mUpdateThread.setEngine(this);
}