7

Is there anyway of doing it?

I can't find any tutorial related to it on google.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Mohammad Areeb Siddiqui
  • 9,795
  • 14
  • 71
  • 113

2 Answers2

7

You really do not need to do anything. You can use any folder in the Desktop project root. For example:

texture = new Texture(Gdx.files.internal("myfolder/libgdx.png"));
Daahrien
  • 10,190
  • 6
  • 39
  • 71
7

Libgdx doesn't enforce any particular hierarchy or folder naming conventions for keeping your assets such that Gdx.files.internal("myassets/libgdx.png") would work just fine on Desktop. However, Android projects do have a specific folder in its root named assets. The folder has to be strictly named "assets" as enforced by the Android project [1]. Therefore, it would be a better idea to lay your folder hierarchy the same way in other projects as well so that you won't have to make changes for individual platforms. A much better approach would be to just place your resources in the Android project and link them to other projects. This would allow you to update your resources in only one project and that would be reflected everywhere. This has been explained in detail here.

And as an informative note, start using AssetManager to manage assets for your Libgdx project as it would streamline asset handling to a great degree.

ug_
  • 11,267
  • 2
  • 35
  • 52
Rafay
  • 6,108
  • 11
  • 51
  • 71
  • 2
    The thing is that actually I created a folder named assets in the main project and then linked it to the other projects. This was my approach which had worked. And yes thanks for the recommendation of the AssetManagar class, this recommendation rewarded you a upvote. Thanks again. :) – Mohammad Areeb Siddiqui Dec 22 '13 at 13:48
  • 2
    wut? He specified "without creating an android project", my answer is the more correct one... but ok I guess. Congrats on your check mark thief hat :p – Daahrien Dec 22 '13 at 17:20
  • 1
    Well it was his choice to select mine and I couldn't do any thing about that. :p Besides, my answer do imply that `Gdx.files.internal("myassets/libgdx.png")` would work just fine without an Android project. I don't like stealing but anyway, the check mark is mine for now. :p Sorry. – Rafay Dec 22 '13 at 17:48