LibGDX, GDX.files.internal() File not found









up vote
0
down vote

favorite












I have an issue using LibGDX with assets directory. I actually build my project folder this way. I follow this tutorial to learn. (I work on Eclipse)
The code I use is :



package com.mygdx.game;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.utils.Timer.Task;

public class MyGdxGame implements ApplicationListener {
private SpriteBatch batch;
private TextureAtlas textureAtlas;
private Sprite sprite;
private int currentFrame = 1;
private String currentAtlasKey = new String("0001");

@Override
public void create()
batch = new SpriteBatch();
// THE PROBLEM IS UNDER THIS LINE
textureAtlas = new TextureAtlas(Gdx.files.internal("spritesheet.atlas"));
AtlasRegion region = textureAtlas.findRegion("0001");
sprite = new Sprite(region);
sprite.setPosition(120, 100);
sprite.scale(2.5f);
Timer.schedule(new Task()
@Override
public void run()
currentFrame++;
if(currentFrame > 20)
currentFrame = 1;

// ATTENTION! String.format() doesnt work under GWT for god knows why...
currentAtlasKey = String.format("%04d", currentFrame);
sprite.setRegion(textureAtlas.findRegion(currentAtlasKey));


,0,1/30.0f);


@Override
public void dispose()
batch.dispose();
textureAtlas.dispose();


@Override
public void render()
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

batch.begin();
sprite.draw(batch);
batch.end();


@Override
public void resize(int width, int height)


@Override
public void pause()


@Override
public void resume()



(if the code is hard to read I use exactly the same code that is in the tutorial linked below)



My package explorer looks like this :
imgur link



And it returns me :




Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: File not found: spritesheet.atlas (Internal)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
at com.badlogic.gdx.graphics.g2d.TextureAtlas$TextureAtlasData.(TextureAtlas.java:103)
at com.badlogic.gdx.graphics.g2d.TextureAtlas.(TextureAtlas.java:231)
at com.badlogic.gdx.graphics.g2d.TextureAtlas.(TextureAtlas.java:226)
at com.badlogic.gdx.graphics.g2d.TextureAtlas.(TextureAtlas.java:216)
at com.mygdx.game.MyGdxGame.create(MyGdxGame.java:23)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:149)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)




I tried some trick like Project>Clean, refreshing, close and re-open Eclipse and even recreated a project. Any idea ?










share|improve this question

























    up vote
    0
    down vote

    favorite












    I have an issue using LibGDX with assets directory. I actually build my project folder this way. I follow this tutorial to learn. (I work on Eclipse)
    The code I use is :



    package com.mygdx.game;

    import com.badlogic.gdx.ApplicationListener;
    import com.badlogic.gdx.Gdx;
    import com.badlogic.gdx.graphics.GL20;
    import com.badlogic.gdx.graphics.g2d.Sprite;
    import com.badlogic.gdx.graphics.g2d.SpriteBatch;
    import com.badlogic.gdx.graphics.g2d.TextureAtlas;
    import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
    import com.badlogic.gdx.utils.Timer;
    import com.badlogic.gdx.utils.Timer.Task;

    public class MyGdxGame implements ApplicationListener {
    private SpriteBatch batch;
    private TextureAtlas textureAtlas;
    private Sprite sprite;
    private int currentFrame = 1;
    private String currentAtlasKey = new String("0001");

    @Override
    public void create()
    batch = new SpriteBatch();
    // THE PROBLEM IS UNDER THIS LINE
    textureAtlas = new TextureAtlas(Gdx.files.internal("spritesheet.atlas"));
    AtlasRegion region = textureAtlas.findRegion("0001");
    sprite = new Sprite(region);
    sprite.setPosition(120, 100);
    sprite.scale(2.5f);
    Timer.schedule(new Task()
    @Override
    public void run()
    currentFrame++;
    if(currentFrame > 20)
    currentFrame = 1;

    // ATTENTION! String.format() doesnt work under GWT for god knows why...
    currentAtlasKey = String.format("%04d", currentFrame);
    sprite.setRegion(textureAtlas.findRegion(currentAtlasKey));


    ,0,1/30.0f);


    @Override
    public void dispose()
    batch.dispose();
    textureAtlas.dispose();


    @Override
    public void render()
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.begin();
    sprite.draw(batch);
    batch.end();


    @Override
    public void resize(int width, int height)


    @Override
    public void pause()


    @Override
    public void resume()



    (if the code is hard to read I use exactly the same code that is in the tutorial linked below)



    My package explorer looks like this :
    imgur link



    And it returns me :




    Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: File not found: spritesheet.atlas (Internal)
    at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
    at com.badlogic.gdx.graphics.g2d.TextureAtlas$TextureAtlasData.(TextureAtlas.java:103)
    at com.badlogic.gdx.graphics.g2d.TextureAtlas.(TextureAtlas.java:231)
    at com.badlogic.gdx.graphics.g2d.TextureAtlas.(TextureAtlas.java:226)
    at com.badlogic.gdx.graphics.g2d.TextureAtlas.(TextureAtlas.java:216)
    at com.mygdx.game.MyGdxGame.create(MyGdxGame.java:23)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:149)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)




    I tried some trick like Project>Clean, refreshing, close and re-open Eclipse and even recreated a project. Any idea ?










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have an issue using LibGDX with assets directory. I actually build my project folder this way. I follow this tutorial to learn. (I work on Eclipse)
      The code I use is :



      package com.mygdx.game;

      import com.badlogic.gdx.ApplicationListener;
      import com.badlogic.gdx.Gdx;
      import com.badlogic.gdx.graphics.GL20;
      import com.badlogic.gdx.graphics.g2d.Sprite;
      import com.badlogic.gdx.graphics.g2d.SpriteBatch;
      import com.badlogic.gdx.graphics.g2d.TextureAtlas;
      import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
      import com.badlogic.gdx.utils.Timer;
      import com.badlogic.gdx.utils.Timer.Task;

      public class MyGdxGame implements ApplicationListener {
      private SpriteBatch batch;
      private TextureAtlas textureAtlas;
      private Sprite sprite;
      private int currentFrame = 1;
      private String currentAtlasKey = new String("0001");

      @Override
      public void create()
      batch = new SpriteBatch();
      // THE PROBLEM IS UNDER THIS LINE
      textureAtlas = new TextureAtlas(Gdx.files.internal("spritesheet.atlas"));
      AtlasRegion region = textureAtlas.findRegion("0001");
      sprite = new Sprite(region);
      sprite.setPosition(120, 100);
      sprite.scale(2.5f);
      Timer.schedule(new Task()
      @Override
      public void run()
      currentFrame++;
      if(currentFrame > 20)
      currentFrame = 1;

      // ATTENTION! String.format() doesnt work under GWT for god knows why...
      currentAtlasKey = String.format("%04d", currentFrame);
      sprite.setRegion(textureAtlas.findRegion(currentAtlasKey));


      ,0,1/30.0f);


      @Override
      public void dispose()
      batch.dispose();
      textureAtlas.dispose();


      @Override
      public void render()
      Gdx.gl.glClearColor(0, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

      batch.begin();
      sprite.draw(batch);
      batch.end();


      @Override
      public void resize(int width, int height)


      @Override
      public void pause()


      @Override
      public void resume()



      (if the code is hard to read I use exactly the same code that is in the tutorial linked below)



      My package explorer looks like this :
      imgur link



      And it returns me :




      Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: File not found: spritesheet.atlas (Internal)
      at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
      at com.badlogic.gdx.graphics.g2d.TextureAtlas$TextureAtlasData.(TextureAtlas.java:103)
      at com.badlogic.gdx.graphics.g2d.TextureAtlas.(TextureAtlas.java:231)
      at com.badlogic.gdx.graphics.g2d.TextureAtlas.(TextureAtlas.java:226)
      at com.badlogic.gdx.graphics.g2d.TextureAtlas.(TextureAtlas.java:216)
      at com.mygdx.game.MyGdxGame.create(MyGdxGame.java:23)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:149)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)




      I tried some trick like Project>Clean, refreshing, close and re-open Eclipse and even recreated a project. Any idea ?










      share|improve this question













      I have an issue using LibGDX with assets directory. I actually build my project folder this way. I follow this tutorial to learn. (I work on Eclipse)
      The code I use is :



      package com.mygdx.game;

      import com.badlogic.gdx.ApplicationListener;
      import com.badlogic.gdx.Gdx;
      import com.badlogic.gdx.graphics.GL20;
      import com.badlogic.gdx.graphics.g2d.Sprite;
      import com.badlogic.gdx.graphics.g2d.SpriteBatch;
      import com.badlogic.gdx.graphics.g2d.TextureAtlas;
      import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
      import com.badlogic.gdx.utils.Timer;
      import com.badlogic.gdx.utils.Timer.Task;

      public class MyGdxGame implements ApplicationListener {
      private SpriteBatch batch;
      private TextureAtlas textureAtlas;
      private Sprite sprite;
      private int currentFrame = 1;
      private String currentAtlasKey = new String("0001");

      @Override
      public void create()
      batch = new SpriteBatch();
      // THE PROBLEM IS UNDER THIS LINE
      textureAtlas = new TextureAtlas(Gdx.files.internal("spritesheet.atlas"));
      AtlasRegion region = textureAtlas.findRegion("0001");
      sprite = new Sprite(region);
      sprite.setPosition(120, 100);
      sprite.scale(2.5f);
      Timer.schedule(new Task()
      @Override
      public void run()
      currentFrame++;
      if(currentFrame > 20)
      currentFrame = 1;

      // ATTENTION! String.format() doesnt work under GWT for god knows why...
      currentAtlasKey = String.format("%04d", currentFrame);
      sprite.setRegion(textureAtlas.findRegion(currentAtlasKey));


      ,0,1/30.0f);


      @Override
      public void dispose()
      batch.dispose();
      textureAtlas.dispose();


      @Override
      public void render()
      Gdx.gl.glClearColor(0, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

      batch.begin();
      sprite.draw(batch);
      batch.end();


      @Override
      public void resize(int width, int height)


      @Override
      public void pause()


      @Override
      public void resume()



      (if the code is hard to read I use exactly the same code that is in the tutorial linked below)



      My package explorer looks like this :
      imgur link



      And it returns me :




      Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: File not found: spritesheet.atlas (Internal)
      at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:136)
      at com.badlogic.gdx.graphics.g2d.TextureAtlas$TextureAtlasData.(TextureAtlas.java:103)
      at com.badlogic.gdx.graphics.g2d.TextureAtlas.(TextureAtlas.java:231)
      at com.badlogic.gdx.graphics.g2d.TextureAtlas.(TextureAtlas.java:226)
      at com.badlogic.gdx.graphics.g2d.TextureAtlas.(TextureAtlas.java:216)
      at com.mygdx.game.MyGdxGame.create(MyGdxGame.java:23)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:149)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:126)




      I tried some trick like Project>Clean, refreshing, close and re-open Eclipse and even recreated a project. Any idea ?







      java eclipse libgdx






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 19:07









      SamHel

      65




      65






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          maybe you haven't linked the asset folder, if so,



          try right click on my-gdx-game-desktop, in properties dialog select Java Build Path, click link source button, then navigate to the assets folder.



          if you're already set it, try readd with this step, restart eclipse if needed






          share|improve this answer




















          • Thank's for your answer, wasn't that in my case. But I know it can be a reason why it doesn't work indeed.
            – SamHel
            Nov 11 at 10:11

















          up vote
          0
          down vote



          accepted










          Okay, I found the trick. For those which encounter the same issue (working on Eclipse but it's pretty the same whatever the IDE is) there is one thread on stack overflow already existing which give additional solutions.
          For me I had to set-up the "working directory" (for the desktop main for exemple). To do this go on Run>Run configuration>Arguments and at working directory's section there is Default and Other. Tick Other's box and me I had to write $workspace_loc:my-gdx-game-core/assets but I think it works like $workspace_loc:[name-of-your-core-directory]/assets. Hope it helped.






          share|improve this answer




















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242459%2flibgdx-gdx-files-internal-file-not-found%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            maybe you haven't linked the asset folder, if so,



            try right click on my-gdx-game-desktop, in properties dialog select Java Build Path, click link source button, then navigate to the assets folder.



            if you're already set it, try readd with this step, restart eclipse if needed






            share|improve this answer




















            • Thank's for your answer, wasn't that in my case. But I know it can be a reason why it doesn't work indeed.
              – SamHel
              Nov 11 at 10:11














            up vote
            0
            down vote













            maybe you haven't linked the asset folder, if so,



            try right click on my-gdx-game-desktop, in properties dialog select Java Build Path, click link source button, then navigate to the assets folder.



            if you're already set it, try readd with this step, restart eclipse if needed






            share|improve this answer




















            • Thank's for your answer, wasn't that in my case. But I know it can be a reason why it doesn't work indeed.
              – SamHel
              Nov 11 at 10:11












            up vote
            0
            down vote










            up vote
            0
            down vote









            maybe you haven't linked the asset folder, if so,



            try right click on my-gdx-game-desktop, in properties dialog select Java Build Path, click link source button, then navigate to the assets folder.



            if you're already set it, try readd with this step, restart eclipse if needed






            share|improve this answer












            maybe you haven't linked the asset folder, if so,



            try right click on my-gdx-game-desktop, in properties dialog select Java Build Path, click link source button, then navigate to the assets folder.



            if you're already set it, try readd with this step, restart eclipse if needed







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 11 at 3:48









            merecoin

            1615




            1615











            • Thank's for your answer, wasn't that in my case. But I know it can be a reason why it doesn't work indeed.
              – SamHel
              Nov 11 at 10:11
















            • Thank's for your answer, wasn't that in my case. But I know it can be a reason why it doesn't work indeed.
              – SamHel
              Nov 11 at 10:11















            Thank's for your answer, wasn't that in my case. But I know it can be a reason why it doesn't work indeed.
            – SamHel
            Nov 11 at 10:11




            Thank's for your answer, wasn't that in my case. But I know it can be a reason why it doesn't work indeed.
            – SamHel
            Nov 11 at 10:11












            up vote
            0
            down vote



            accepted










            Okay, I found the trick. For those which encounter the same issue (working on Eclipse but it's pretty the same whatever the IDE is) there is one thread on stack overflow already existing which give additional solutions.
            For me I had to set-up the "working directory" (for the desktop main for exemple). To do this go on Run>Run configuration>Arguments and at working directory's section there is Default and Other. Tick Other's box and me I had to write $workspace_loc:my-gdx-game-core/assets but I think it works like $workspace_loc:[name-of-your-core-directory]/assets. Hope it helped.






            share|improve this answer
























              up vote
              0
              down vote



              accepted










              Okay, I found the trick. For those which encounter the same issue (working on Eclipse but it's pretty the same whatever the IDE is) there is one thread on stack overflow already existing which give additional solutions.
              For me I had to set-up the "working directory" (for the desktop main for exemple). To do this go on Run>Run configuration>Arguments and at working directory's section there is Default and Other. Tick Other's box and me I had to write $workspace_loc:my-gdx-game-core/assets but I think it works like $workspace_loc:[name-of-your-core-directory]/assets. Hope it helped.






              share|improve this answer






















                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                Okay, I found the trick. For those which encounter the same issue (working on Eclipse but it's pretty the same whatever the IDE is) there is one thread on stack overflow already existing which give additional solutions.
                For me I had to set-up the "working directory" (for the desktop main for exemple). To do this go on Run>Run configuration>Arguments and at working directory's section there is Default and Other. Tick Other's box and me I had to write $workspace_loc:my-gdx-game-core/assets but I think it works like $workspace_loc:[name-of-your-core-directory]/assets. Hope it helped.






                share|improve this answer












                Okay, I found the trick. For those which encounter the same issue (working on Eclipse but it's pretty the same whatever the IDE is) there is one thread on stack overflow already existing which give additional solutions.
                For me I had to set-up the "working directory" (for the desktop main for exemple). To do this go on Run>Run configuration>Arguments and at working directory's section there is Default and Other. Tick Other's box and me I had to write $workspace_loc:my-gdx-game-core/assets but I think it works like $workspace_loc:[name-of-your-core-directory]/assets. Hope it helped.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 11 at 10:10









                SamHel

                65




                65



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242459%2flibgdx-gdx-files-internal-file-not-found%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    這個網誌中的熱門文章

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3

                    Museum of Modern and Contemporary Art of Trento and Rovereto