LibGDX's TexturePacker with gradle

只愿长相守 提交于 2019-11-30 13:51:06

I got it working by adding gdx-tools to my buildscript dependencies:

buildscript{
    dependencies {
       ...
       classpath 'com.badlogicgames.gdx:gdx-tools:1.5.4'
    }
}

by doing this, my desktop's build.gradle was able to import the texture packer class:

import com.badlogic.gdx.tools.texturepacker.TexturePacker
task texturePacker << {
    if (project.ext.has('texturePacker')) {
        logger.info "Calling TexturePacker: "+ texturePacker
        TexturePacker.process(texturePacker[0], texturePacker[1], texturePacker[2])
    }
}

please note that your desktop project's ext will need to have texturePacker defined:

project.ext {
    mainClassName = "your.game.package.DesktopLauncher"
    assetsDir = new File("../android/assets");
    texturePacker = ["../images/sprites", "../android/assets", "sprites"]
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!