Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

android - LibGdx resolutionFileResolver + Assetmanager, file names?

I want to use the resolution file resolver to select a correct texture atlas for my app, so I createa RFR with a couple of resolutions:

Resolution _568x1136 = new Resolution(568, 1136, ".568x1136");
Resolution _1200x1920 = new Resolution(568, 1136, ".1200x1920");
ResolutionFileResolver resolver = new ResolutionFileResolver(new InternalFileHandleResolver(), _568x1136, _1200x1920);

manager = new AssetManager();
manager.setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver));

Now I'm wondering, how do I name/place the files??????

I tried adding .1200x1920 and .568x1136 behind BOTH the .png and the .atlas (.png.568.1136, etc), but that didn't work.

I also tried using folders (parent/568x1136/file.atlas).

I try to load the atlas in the following manner:

manager.load("data/atlas/splashscreen/splashscreen.atlas", TextureAtlas.class);                     // First make sure the splash screen
manager.finishLoading();                                                                            // is loaded before loading anything
Assets.splashAtlas = manager.get("data/atlas/splashscreen/splashscreen.atlas", TextureAtlas.class); // else 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
// no dots were used for the "suffix"
Resolution _568x1136 = new Resolution(568, 1136, "568x1136");
Resolution _1200x1920 = new Resolution(568, 1136, "1200x1920");
ResolutionFileResolver resolver = new ResolutionFileResolver(new InternalFileHandleResolver(), _568x1136, _1200x1920);

manager.load("data/atlas/splashscreen/splashscreen.atlas", TextureAtlas.class);                     
manager.finishLoading();                                                                      
Assets.splashAtlas = manager.get("data/atlas/splashscreen/splashscreen.atlas", TextureAtlas.class);

Despite other answers on stackoverflow regarding the ResolutionFileResolver, it actually does make use of a folder hierarchy to retrieve the correct images. If we assume that 568x1136 would be the best matching resolution, it will search for data/atlas/splashscreen/568x1136/splashscreen.atlas now. If this file cannot be found, the fallback will be just data/atlas/splashscreen/splashscreen.atlas. If this file also doesn't exist, an exception will occur.

So the name "suffix" is not really correct anymore. The implementation seems to have changed over time. The "suffix" is not being appended to the files anymore.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...