LibGDX#39;s TexturePacker with gradle(带有 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.
所以我有几个问题:
texturePacker
任务的正确位置在哪里?我应该把它放在哪个build.gradle
中?
Where is the correct place for the
texturePacker
task? Whichbuild.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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:带有 gradle 的 LibGDX 的 TexturePacker
基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01