2016-12-12 2 views
0

Im Sprite를로드하기 위해 LibGDX에서 구현 한 TexturePacker를 사용하고 있습니다. 그러나 어떤 이유로, 파일이 발견하고 나에게이 예외를 제공하지 않습니다 :내 텍스처 패커가 스프라이트를 찾지 못하는 이유는 무엇입니까?

public static void main (String[] arg) { 
    LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); 
    config.width = 800; 
    config.height = 800; 

    deleteFiles(); 
    processSprites(); 

    new LwjglApplication(new OneRoom(), config); 
} 

public static void deleteFiles() { 
    File outputDir = new File("../android/assets/sprites/output"); 
    File[] listFiles = outputDir.listFiles(); 
    if (listFiles != null && listFiles.length > 0) {     
     for (File file : listFiles) { 
      file.delete(); 
     } 
    } 
} 

public static void processSprites() { 
    TexturePacker.Settings settings = new TexturePacker.Settings(); 
    //System.out.println(Gdx.files.internal("sprites/input/player.png").toString()); 
    TexturePacker.process(settings, "sprites/input", "sprites/output", "pack"); // THIS LINE CAUSES THE ERROR 
} 

내가 또 다른 프로젝트에서 동일한 코드를 가지고와이 코드는 오류의 원인이

Exception in thread "main" java.lang.RuntimeException: Error packing images. 
at com.badlogic.gdx.tools.texturepacker.TexturePacker.process(TexturePacker.java:620) 
at com.zebleck.OneRoom.desktop.DesktopLauncher.processSprites(DesktopLauncher.java:35) 
at com.zebleck.OneRoom.desktop.DesktopLauncher.main(DesktopLauncher.java:17) 
Caused by: java.lang.IllegalArgumentException: Input file does not exist: C:\Users\Kontor\Desktop\Codeporn\LibGDX-workspace\OneRoom\desktop\sprites\input 
at com.badlogic.gdx.tools.FileProcessor.process(FileProcessor.java:117) 
at com.badlogic.gdx.tools.texturepacker.TexturePackerFileProcessor.process(TexturePackerFileProcessor.java:70) 
at com.badlogic.gdx.tools.texturepacker.TexturePacker.process(TexturePacker.java:618) 
... 2 more 

그것은 잘 작동합니다. 아직 프로젝트 속성에 차이점을 발견하지 못했습니다.

+0

입력 스프라이트를 C : \ Users \ Kontor \ Desktop \ Codeporn \ LibGDX-workspace \ OneRoom \ desktop \ sprites \ input에 복사 했습니까? – Hllink

+0

작업 디렉토리는 실행 구성에서'sprites /'가 들어있는 디렉토리로 설정되어야합니다. – Tenfour04

답변

0

해당 디렉토리에 실제로 스프라이트가 존재하는지 확인하십시오.

미안하지만 나는 똑같은 문제를 겪고 있었고 데스크톱 프로젝트의 내 자산 디렉토리가 내 핵심 프로젝트의 자산 폴더에 대한 참조 일 뿐인 "링크 된 폴더"라는 오해를 받고있었습니다. 따라서 폴더가 존재하고 아무 문제도 없어 보이지만 파일 탐색기를 통해 보면 파일이 실제로 그 위치에 존재하지 않았다는 것이 확실합니다.

필자는 입력 및 출력을 단계적으로 변경하고 바탕 화면 대신 코어 디렉토리를 확인하도록 수정했습니다.

그래서 대신 :

TexturePacker.process(settings, "sprites/input", "sprites/output", "pack"); 

다음은 작동합니다 : 이제

TexturePacker.process(settings, "../core/sprites/input", "../core/sprites/output", "pack"); 

나는 당신의 정확한 설정을 알고 있지만 코드를 고려하면 내가 그 내기 것이 다른 프로젝트에서 작동하지 않는 다른 프로젝트는 데스크탑 디렉토리에 실제로 저장된 자산을 가지고 있습니다.이 자산은 코어 디렉토리에 이미지를 저장합니다.