首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带梯度的LibGDX TexturePacker

带梯度的LibGDX TexturePacker
EN

Stack Overflow用户
提问于 2015-06-15 22:53:47
回答 1查看 2.2K关注 0票数 8

我正在尝试创建一个gradle任务,它按照TexturePacker的这里指令运行。(请注意,我使用的是Android及其目录结构,而不是Eclipse。)我首先在Android项目的build.gradle中添加了以下内容

代码语言:javascript
复制
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])
  }
}

这就产生了错误

无法解析类com.badlogic.gdx.tools.texturepacker.TexturePacker

texturePacker任务移动到桌面项目中的build.gradle会产生相同的错误。根据纹理包装器2/,我还需要将compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"添加到桌面项目依赖项下的根build.gradle中。当我这样做时,我仍然得到相同的错误。

所以我有几个问题:

  1. texturePacker任务的正确位置在哪里?我把这个放哪一个build.gradle
  2. 如何解决依赖问题和unable to resolve class...错误?
  3. 在使用gradle运行此命令时,如何指定输入和输出目录和地图文件?(假设前两个问题已经解决。)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-07-27 05:30:09

我通过将gdx-tools添加到构建脚本依赖项中来使其工作:

代码语言:javascript
复制
buildscript{
    dependencies {
       ...
       classpath 'com.badlogicgames.gdx:gdx-tools:1.5.4'
    }
}

通过这样做,我的桌面的build.gradle能够导入纹理打包器类:

代码语言:javascript
复制
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])
    }
}

请注意,您的桌面项目的ext需要定义texturePacker:

代码语言:javascript
复制
project.ext {
    mainClassName = "your.game.package.DesktopLauncher"
    assetsDir = new File("../android/assets");
    texturePacker = ["../images/sprites", "../android/assets", "sprites"]
}
票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30856278

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档