Search in sources :

Example 1 with FreetypeFontLoader

use of com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader in project libgdx by libgdx.

the class APKExpansionTest method create.

@Override
public void create() {
    if ((((AndroidFiles) Gdx.files)).setAPKExpansion(1, 0)) {
        resolver = new ZipFileHandleResolver();
    } else {
        Gdx.app.error("libgdx", "No Expansion can be opened");
    }
    assetManager = new AssetManager();
    FileHandleResolver resolver = new InternalFileHandleResolver();
    assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    assetManager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
    loadFont(assetManager, "data/DroidSerif-Regular.ttf", 12);
    loadFont(assetManager, "data/" + extensionPrefix + "DroidSerif-Regular.ttf", 12);
    assetManager.load("data/" + extensionPrefix + "testpackobb", TextureAtlas.class);
    assetManager.finishLoading();
    sound = Gdx.audio.newSound(Gdx.files.internal("data/" + extensionPrefix + "chirp.ogg"));
    sound.play();
    texture = new Texture(resolver.resolve("data/" + extensionPrefix + "badlogic.jpg"));
    batch = new SpriteBatch();
    TextureAtlas atlas = assetManager.get("data/" + extensionPrefix + "testpackobb");
    atlasTextureRegion = new TextureRegion(atlas.findRegion("water"));
    sound = Gdx.audio.newSound(Gdx.files.internal("data/shotgun.ogg"));
    sound.play();
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) AssetManager(com.badlogic.gdx.assets.AssetManager) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) FileHandleResolver(com.badlogic.gdx.assets.loaders.FileHandleResolver) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) FreeTypeFontGeneratorLoader(com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader) FreetypeFontLoader(com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 2 with FreetypeFontLoader

use of com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader in project libgdx by libgdx.

the class FreeTypeFontLoaderTest method create.

@Override
public void create() {
    manager = new AssetManager();
    // set the loaders for the generator and the fonts themselves
    FileHandleResolver resolver = new InternalFileHandleResolver();
    manager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    manager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
    // load to fonts via the generator (implicitely done by the FreetypeFontLoader).
    // Note: you MUST specify a FreetypeFontGenerator defining the ttf font file name and the size
    // of the font to be generated. The names of the fonts are arbitrary and are not pointing
    // to a file on disk!
    FreeTypeFontLoaderParameter size1Params = new FreeTypeFontLoaderParameter();
    size1Params.fontFileName = "data/arial.ttf";
    size1Params.fontParameters.size = 10;
    manager.load("size10.ttf", BitmapFont.class, size1Params);
    FreeTypeFontLoaderParameter size2Params = new FreeTypeFontLoaderParameter();
    size2Params.fontFileName = "data/arial.ttf";
    size2Params.fontParameters.size = 20;
    manager.load("size20.ttf", BitmapFont.class, size2Params);
    // we also load a "normal" font generated via Hiero
    manager.load("data/default.fnt", BitmapFont.class);
    batch = new SpriteBatch();
}
Also used : FreeTypeFontLoaderParameter(com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader.FreeTypeFontLoaderParameter) AssetManager(com.badlogic.gdx.assets.AssetManager) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) FileHandleResolver(com.badlogic.gdx.assets.loaders.FileHandleResolver) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) FreeTypeFontGeneratorLoader(com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader) FreetypeFontLoader(com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 3 with FreetypeFontLoader

use of com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader in project ProjektGG by eskalon.

the class ProjektGG method create.

@Override
public final void create() {
    if (debug)
        Gdx.app.setLogLevel(Gdx.app.LOG_DEBUG);
    else
        Gdx.app.setLogLevel(Gdx.app.LOG_INFO);
    // Initialize sprite batch
    this.batch = new SpriteBatch();
    // Initialize asset manager
    FileHandleResolver resolver = new InternalFileHandleResolver();
    this.assetManager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    this.assetManager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
    this.assetManager.setLoader(Text.class, new TextLoader(new InternalFileHandleResolver()));
    this.viewportWidth = Gdx.graphics.getWidth();
    this.viewportHeight = Gdx.graphics.getHeight();
    // Initialize cameras
    this.uiCamera = new OrthographicCamera(viewportWidth, viewportHeight);
    this.uiCamera.translate(viewportWidth / 2, viewportHeight / 2, 0);
    this.uiCamera.update();
    this.gameCamera = new CameraWrapper(new PerspectiveCamera(67, viewportWidth, viewportHeight));
    this.gameCamera.getCamera().translate(viewportWidth / 2, viewportHeight / 2, 0);
    // this.camera.update();
    this.batch.setProjectionMatrix(this.gameCamera.getCamera().combined);
    // Load game settings
    this.settings = new GameSettings("projekt-gg");
    // Create the event bus
    this.eventBus = new EventQueueBus();
    // Create the network handler
    this.networkHandler = new NetworkHandler(eventBus);
    // Set input processor
    Gdx.input.setInputProcessor(inputProcessor);
    // Add screens
    addScreen("splash", new SplashScreen());
    addScreen("mainMenu", new MainMenuScreen());
    addScreen("loading", new LoadingScreen());
    addScreen("gameLoading", new GameLoadingScreen());
    addScreen("serverBrowser", new ServerBrowserScreen());
    addScreen("lobby", new LobbyScreen());
    addScreen("lobbyCreation", new LobbyCreationScreen());
    addScreen("map", new GameMapScreen());
    addScreen("house", new GameInHouseScreen());
    addScreen("roundEnd", new GameRoundendScreen());
    // Push screen
    if (showSplashscreen)
        pushScreen("splash");
    else
        pushScreen("loading");
}
Also used : GameLoadingScreen(de.gg.screen.GameLoadingScreen) EventQueueBus(de.gg.util.EventQueueBus) ServerBrowserScreen(de.gg.screen.ServerBrowserScreen) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) FreeTypeFontGeneratorLoader(com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) GameLoadingScreen(de.gg.screen.GameLoadingScreen) LoadingScreen(de.gg.screen.LoadingScreen) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) GameInHouseScreen(de.gg.screen.GameInHouseScreen) GameRoundendScreen(de.gg.screen.GameRoundendScreen) TextLoader(de.gg.util.asset.TextLoader) FileHandleResolver(com.badlogic.gdx.assets.loaders.FileHandleResolver) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) InternalFileHandleResolver(com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver) SplashScreen(de.gg.screen.SplashScreen) NetworkHandler(de.gg.network.NetworkHandler) GameMapScreen(de.gg.screen.GameMapScreen) GameSettings(de.gg.setting.GameSettings) MainMenuScreen(de.gg.screen.MainMenuScreen) FreetypeFontLoader(com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader) LobbyScreen(de.gg.screen.LobbyScreen) LobbyCreationScreen(de.gg.screen.LobbyCreationScreen) CameraWrapper(de.gg.camera.CameraWrapper)

Aggregations

FileHandleResolver (com.badlogic.gdx.assets.loaders.FileHandleResolver)3 InternalFileHandleResolver (com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver)3 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)3 FreeTypeFontGeneratorLoader (com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGeneratorLoader)3 FreetypeFontLoader (com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader)3 AssetManager (com.badlogic.gdx.assets.AssetManager)2 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)1 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 Texture (com.badlogic.gdx.graphics.Texture)1 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 FreeTypeFontLoaderParameter (com.badlogic.gdx.graphics.g2d.freetype.FreetypeFontLoader.FreeTypeFontLoaderParameter)1 CameraWrapper (de.gg.camera.CameraWrapper)1 NetworkHandler (de.gg.network.NetworkHandler)1 GameInHouseScreen (de.gg.screen.GameInHouseScreen)1 GameLoadingScreen (de.gg.screen.GameLoadingScreen)1 GameMapScreen (de.gg.screen.GameMapScreen)1 GameRoundendScreen (de.gg.screen.GameRoundendScreen)1 LoadingScreen (de.gg.screen.LoadingScreen)1 LobbyCreationScreen (de.gg.screen.LobbyCreationScreen)1