带有 gradle 的 LibGDX 的 TexturePacker

LibGDX#39;s TexturePacker with gradle(带有 gradle 的 LibGDX 的 TexturePacker)
本文介绍了带有 gradle 的 LibGDX 的 TexturePacker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个根据说明运行 TexturePacker 的 gradle 任务 这里.(请注意,我使用的是 Android Studio 及其目录结构,而不是 Eclipse.)我首先将以下内容添加到 Android Studio 项目的 build.gradle:

I am attempting to create a gradle task which runs TexturePacker according to the instructions here. (Note that I am using Android Studio and its directory structure rather than Eclipse.) I first added the following to the Android Studio project's build.gradle:

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 类

unable to resolve class com.badlogic.gdx.tools.texturepacker.TexturePacker

texturePacker 任务移动到桌面项目中的 build.gradle 会产生相同的错误.根据 http://www.reddit.com/r/libgdx/comments/2fx3vf/could_not_find_or_load_main_class_texturepacker2/,我还需要在根build.gradle下添加compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"桌面项目的依赖项.当我这样做时,我仍然得到同样的错误.

Moving the texturePacker task to build.gradle in the desktop project produces the same error. According to http://www.reddit.com/r/libgdx/comments/2fx3vf/could_not_find_or_load_main_class_texturepacker2/, I also need to add compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion" to the root build.gradle under the desktop project's dependencies. When I do so, I still get the same error.

所以我有几个问题:

  1. texturePacker 任务的正确位置在哪里?我应该把它放在哪个 build.gradle 中?

  1. Where is the correct place for the texturePacker task? Which build.gradle do I put this in?

如何解决依赖问题和unable to resolve class...错误?

How do I solve the dependency issue and the unable to resolve class... error?

使用 gradle 运行时如何指定输入输出目录和 atlas 文件?(假设前两个问题已经解决.)

How do I specify the input and output directories and the atlas file when running this with gradle? (Assuming the first two questions are solved.)

推荐答案

我通过将 gdx-tools 添加到我的 buildscript 依赖项中使其工作:

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

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

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

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])
    }
}

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

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"]
}

这篇关于带有 gradle 的 LibGDX 的 TexturePacker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
Dropbox Files.download does not start when number of files in folder is gt; 1000(当文件夹中的文件数为1000时,Dropbox Files.Download不会启动)
How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)