Added createTiledFromAssetDirectory() method to BitmapTextureAtlasTextureRegionFactory #99

Merged
merged 2 commits into from May 14, 2012

Conversation

Projects
None yet
2 participants
Contributor

nazgee commented May 3, 2012

This method allows to load mutliple assets from a given directory to a
single ITiledTextureRegion.

Instead of loading multiple assets one by one it is sometimes convinient to do sth like this:

ITiledTextureRegion TEXS_SUNSHINE = BitmapTextureAtlasTextureRegionFactory.createTiledFromAssetDirectory(
                    atlasSunshine, c.getAssets(), "shine");

And have dozen of sunshine files from gfx/shine directory loaded as tiles of ITiledTextureRegion in just one go.

.../opengl/texture/atlas/bitmap/BitmapTextureAtlasTextureRegionFactory.java
+ throw new RuntimeException("Listing assets directory failed! " + getAssetBasePath() + pAssetsSubdirectory + " does not exist?", ioex);
+ }
+
+ int i = 0;
@nicolasgramlich

nicolasgramlich May 7, 2012

Owner

Can we convert this to a index based for loop?

@nazgee

nazgee May 7, 2012

Contributor

will do... though after entering Java world from C/C++ universe, this construction seems sooooo hot :)

src/org/andengine/audio/music/MusicFactory.java
@@ -45,6 +45,10 @@ public static void setAssetBasePath(final String pAssetBasePath) {
}
}
+ public static String getAssetBasePath() {
+ return sAssetBasePath;
@nicolasgramlich

nicolasgramlich May 7, 2012

Owner

Can you add the 'scope' to these variables? =)

I mean "sAssetBasePath" -> "MusicFactory.sAssetBasePath"

.../opengl/texture/atlas/bitmap/BitmapTextureAtlasTextureRegionFactory.java
+
+ try {
+ files = pAssetManager.list(getAssetBasePath() + pAssetsSubdirectory);
+ textures = new ITextureRegion[files.length];
@nicolasgramlich

nicolasgramlich May 7, 2012

Owner

Can you move this below the try-catch?

.../opengl/texture/atlas/bitmap/BitmapTextureAtlasTextureRegionFactory.java
+ files = pAssetManager.list(getAssetBasePath() + pAssetsSubdirectory);
+ textures = new ITextureRegion[files.length];
+ } catch (IOException ioex) {
+ throw new RuntimeException("Listing assets directory failed! " + getAssetBasePath() + pAssetsSubdirectory + " does not exist?", ioex);
@nicolasgramlich

nicolasgramlich May 7, 2012

Owner

Can you throw an AndEngineRuntimeException here?

nazgee added some commits May 3, 2012

Added getAssetBasePath() method to all factories
This method was added to all factories that had setAssetBasePath()
method declared.
Added createTiledFromAssetDirectory() method to BitmapTextureAtlasTex…
…tureRegionFactory

This method allows to load mutliple assets from a given directory to a
single ITiledTextureRegion.
Contributor

nazgee commented May 7, 2012

^ fixed all your remarks :)

nicolasgramlich added a commit that referenced this pull request May 14, 2012

Merge pull request #99 from nazgee/for-nicolas-directorytiles
Added createTiledFromAssetDirectory() method to BitmapTextureAtlasTextureRegionFactory.

@nicolasgramlich nicolasgramlich merged commit e799e9e into nicolasgramlich:GLES2 May 14, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment