LibGDX FreeTypeFontGenerator

时间:2014-06-12 14:32:35

标签: java eclipse libgdx freetype

我使用最新的基于Gradle的设置应用程序v1.1.0创建了LibGDX项目。 当我创建时,我没有在项目中添加FreeType扩展。 现在我需要它。如何将其添加到已创建的项目中?

2 个答案:

答案 0 :(得分:11)

来自libGDX's wiki

  

FreeTypeFont Gradle

     

核心依赖:

     
      
  • compile" com.badlogicgames.gdx:gdx-freetype:$ gdxVersion"
  •   
     

桌面依赖关系:

     
      
  • compile" com.badlogicgames.gdx:gdx-freetype-platform:$ gdxVersion:natives-desktop"
  •   
     

Android依赖:

     
      
  • compile" com.badlogicgames.gdx:gdx-freetype:$ gdxVersion"
  •   
  • natives" com.badlogicgames.gdx:gdx-freetype-platform:$ gdxVersion:natives-armeabi"
  •   
  • natives" com.badlogicgames.gdx:gdx-freetype-platform:$ gdxVersion:natives-armeabi-v7a"
  •   
  • natives" com.badlogicgames.gdx:gdx-freetype-platform:$ gdxVersion:natives-x86"
  •   
     

iOS依赖关系:

     
      
  • compile" com.badlogicgames.gdx:gdx-freetype:$ gdxVersion"
  •   
  • natives" com.badlogicgames.gdx:gdx-freetype-platform:$ gdxVersion:natives-ios"
  •   

不要忘记刷新你的依赖项;)

答案 1 :(得分:7)

这是一个包含所有模块的完整build.gradle,您可以看到哪一个与FreeType相关,只需将其添加到您的gradle配置中。

buildscript {
    repositories {
        mavenCentral()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.10+'
        classpath 'com.github.jtakakura:gradle-robovm-plugin:0.0.9'
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = 'klaxon-game'
        gdxVersion = '1.1.0'
        roboVMVersion = '0.0.13'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

project(":desktop") {
    apply plugin: "java"


    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-desktop:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-platform:$gdxVersion:natives-desktop"
    }
}

project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.box2dlights:box2dlights:1.2"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
        compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers-android:$gdxVersion"
    }
}

project(":ios") {
    apply plugin: "java"
    apply plugin: "robovm"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "org.robovm:robovm-rt:${roboVMVersion}"
        compile "org.robovm:robovm-cocoatouch:${roboVMVersion}"
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
        natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
        natives "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios"
        natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
    }
}

project(":core") {
    apply plugin: "java"


    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-bullet:$gdxVersion"
        compile "com.badlogicgames.box2dlights:box2dlights:1.2"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-controllers:$gdxVersion"
    }
}

tasks.eclipse.doLast {
    delete ".project"
}