저는 AssetManager의 인스턴스가 두 개 있습니다. 하나는 기본 텍스처 용이고 다른 하나는 고품질 텍스처 용입니다. 기본 텍스처는 "android/assets"폴더에 있고 고품질 텍스처는 zip 파일로 압축되어 있습니다. 이 폴더의 컨텐츠 (파일 이름)는 동일합니다. 압축 아카이브에는 더 좋은 품질의 텍스처 만 있습니다.AssetManager - libgdx를 통해 zip 아카이브에서 TextureAtlas를로드 할 수 없습니다.
AssetManager는 zip 파일에서 TextureAtlas를로드하려고 할 때 "자산의 종속성을로드 할 수 없습니다 : teamLogo.png"예외를 throw합니다. 텍스쳐 파일을로드 할 때 모든 것이 괜찮습니다. TextureAtlas로드는 'android/assets'폴더에서만 가능합니다. -
'안드로이드/자산'를 사용 AssetManager 모든 것이 괜찮 :
AssetManager am = new AssetManager();
am.load("images/image.png", Texture.class);
am.load("images/teamLogo.pack", TextureAtlas.class);
우편 아카이브를 사용하여
AssetManager - TextureAtlas로드 할 수 없습니다 :
ZipFile archive = new ZipFile(expansionFileHandle.file());
ArchiveFileHandleResolver resolver = new ArchiveFileHandleResolver(archive);
AssetManager amHQ = new AssetManager(resolver);
이 잘 작동 :
amHQ.load("images/image.png", Texture.class);
을
작동하지 않음 :
amHQ.load("images/teamLogo.pack", TextureAtlas.class);
ArchiveFileHandle 클래스 : 내가 잘못
public class ArchiveFileHandle extends FileHandle
{
final ZipFile archive;
final ZipEntry archiveEntry;
public ArchiveFileHandle (ZipFile archive, File file)
{
super(file, FileType.Classpath);
this.archive = archive;
archiveEntry = this.archive.getEntry(file.getPath());
}
public ArchiveFileHandle (ZipFile archive, String fileName)
{
super(fileName.replace('\\', '/'), FileType.Classpath);
this.archive = archive;
this.archiveEntry = archive.getEntry(fileName.replace('\\', '/'));
}
@Override
public FileHandle child (String name)
{
name = name.replace('\\', '/');
if (file.getPath().length() == 0)
return new ArchiveFileHandle(archive, new File(name));
return new ArchiveFileHandle(archive, new File(file, name));
}
@Override
public FileHandle sibling (String name)
{
name = name.replace('\\', '/');
if (file.getPath().length() == 0)
throw new GdxRuntimeException("Cannot get the sibling of the root.");
return new ArchiveFileHandle(archive, new File(file.getParent(), name));
}
@Override
public FileHandle parent()
{
File parent = file.getParentFile();
if (parent == null)
{
if (type == FileType.Absolute)
parent = new File("/");
else
parent = new File("");
}
return new ArchiveFileHandle(archive, parent);
}
@Override
public InputStream read()
{
try
{
return archive.getInputStream(archiveEntry);
}
catch (IOException e)
{
throw new GdxRuntimeException("File not found: " + file + " (Archive)");
}
}
@Override
public boolean exists()
{
return archiveEntry != null;
}
@Override
public long length()
{
return archiveEntry.getSize();
}
@Override
public long lastModified()
{
return archiveEntry.getTime();
}
을 뭐하는 거지?
차이 잘 작동 – Bero