Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (775)
Games in Android Showcase (230)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Android - Assets vs res folder  (Read 8347 times)
0 Members and 1 Guest are viewing this topic.
Offline SauronWatchesYou

JGO Ninja


Medals: 33
Projects: 4
Exp: 2 years


Hi there! :)


« Posted 2015-06-06 12:34:13 »

Hi all.

I've been learning Android recently and so far I've only touched the res folder to put my images/icon inside. However, when I use LibGDX I always put the images/music/sounds inside an assets folder inside the desktop project which then copies those files to the Android assets folder. I have a few questions based on this.

1: If I create different size images and place them inside the assets folder, how does the phone know which images to use? Do I need to change some code, etc?
2: When should I use the res/drawable folders over the assets folder and vice-versa
3: Does it even really matter about different size images? I know some phones/tablets support very large screen sizes and using LibGDX I use the viewport class to keep the aspect ratio, which means I only need 1 set of assets. I don't mind creating multiple assets, just wondering how Android would handle this


Hey, you! Back to work
Offline craftm

JGO Coder


Medals: 15
Projects: 1


_Keep Trying


« Reply #1 - Posted 2015-06-06 14:39:32 »

In the res folder you can use images with different sizes, strings (.xml), special layouts for activities, dimens.xml for dimensions and all the content is automatically selected depending on the resolution of the device.

If you have an image.png in the drawable-ldpi and an image.png in the drawable-hdpi, your app will use the image from the current device without coding anything, same with the values-small/large.

In libGDX you have only one acitivity, so you are a bit more limited with layouts or other features, but you can still use (you can't share the res folder and other specific platform features with desktop/ios/html5, I think). I can be wrong, if you are using libGDX you don't need worry about the res folder for your assets from the game, especially if you are using some types of viewport, but for some Android features you need to use (e.g: icon launcher, androidmanifest.xml, implement some code for advertising banners, leaderboards, etc..).

For the res folder strategy (select different sizes automatically), libGDX has an interesting class called ResolutionFileResolver:
http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/assets/loaders/resolvers/ResolutionFileResolver.html

_ Wink
Offline SauronWatchesYou

JGO Ninja


Medals: 33
Projects: 4
Exp: 2 years


Hi there! :)


« Reply #2 - Posted 2015-06-06 20:19:33 »

Thank you very much, Craftm. Just what I was looking for.

I've never heard of the ResolutionFileResolver class before! Shocked i'm going to take a look at it, could be really useful in the future.

Hey, you! Back to work
Pages: [1]
  ignore  |  Print  
 
 

 
hadezbladez (42 views)
2018-11-16 13:46:03

hadezbladez (44 views)
2018-11-16 13:41:33

hadezbladez (25 views)
2018-11-16 13:35:35

hadezbladez (18 views)
2018-11-16 13:32:03

EgonOlsen (1894 views)
2018-06-10 19:43:48

EgonOlsen (1930 views)
2018-06-10 19:43:44

EgonOlsen (1285 views)
2018-06-10 19:43:20

DesertCoockie (1716 views)
2018-05-13 18:23:11

nelsongames (1404 views)
2018-04-24 18:15:36

nelsongames (2036 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!