\r
import com.badlogic.gdx.assets.AssetManager;\r
import com.badlogic.gdx.graphics.Texture;\r
+import com.badlogic.gdx.graphics.g2d.TextureAtlas;\r
+import com.badlogic.gdx.graphics.g2d.TextureRegion;\r
import com.badlogic.gdx.utils.ObjectMap;\r
\r
/**\r
* @param name\r
* @return the Texture for the given image name or null.\r
*/\r
- public Texture getImage(String name);\r
+ public TextureRegion getImage(String name);\r
\r
public static class DirectImageResolver implements ImageResolver {\r
private final ObjectMap<String, Texture> images;\r
}\r
\r
@Override\r
- public Texture getImage (String name) {\r
- return images.get(name);\r
+ public TextureRegion getImage (String name) {\r
+ return new TextureRegion(images.get(name));\r
}\r
}\r
\r
}\r
\r
@Override\r
- public Texture getImage (String name) {\r
- return assetManager.get(name, Texture.class);\r
+ public TextureRegion getImage (String name) {\r
+ return new TextureRegion(assetManager.get(name, Texture.class));\r
+ }\r
+ }\r
+ \r
+ public static class TextureAtlasImageResolver implements ImageResolver {\r
+ private final TextureAtlas atlas;\r
+ \r
+ public TextureAtlasImageResolver(TextureAtlas atlas) {\r
+ this.atlas = atlas;\r
+ }\r
+ \r
+ @Override\r
+ public TextureRegion getImage (String name) {\r
+ return atlas.findRegion(name);\r
}\r
}\r
}\r
int spacingY = Integer.parseInt(spacingParts[1]);
FileHandle image = getRelativeFileHandle(tideFile, imageSource);
- Texture texture = imageResolver.getImage(image.path());
+ TextureRegion texture = imageResolver.getImage(image.path());
// TODO: Actually load the tilesheet
// Need to make global ids as Tide doesn't have global ids.
tileset.getProperties().put("firstgid", firstgid);
int gid = firstgid;
- int stopWidth = texture.getWidth() - tileSizeX;
- int stopHeight = texture.getHeight() - tileSizeY;
+ int stopWidth = texture.getRegionWidth() - tileSizeX;
+ int stopHeight = texture.getRegionHeight() - tileSizeY;
for (int y = marginY; y <= stopHeight; y += tileSizeY + spacingY) {
for (int x = marginX; x <= stopWidth; x += tileSizeX + spacingX) {
image = getRelativeFileHandle(tmxFile, imageSource);
}
- Texture texture = imageResolver.getImage(image.path());
+ TextureRegion texture = imageResolver.getImage(image.path());
TiledMapTileSet tileset = new TiledMapTileSet();
tileset.setName(name);
- int stopWidth = texture.getWidth() - tilewidth;
- int stopHeight = texture.getHeight() - tileheight;
+ int stopWidth = texture.getRegionWidth() - tilewidth;
+ int stopHeight = texture.getRegionHeight() - tileheight;
int id = firstgid;
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry excluding="**/.svn/*" kind="src" path="src"/>
- <classpathentry excluding="**/.svn/*" kind="src" path="gen"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-backend-android"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-tests"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-audio"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-freetype"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-image"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-bullet"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-controllers"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-controllers-android"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry excluding="**/.svn/*" kind="src" path="src"/>\r
+ <classpathentry excluding="**/.svn/*" kind="src" path="gen"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-backend-android"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-tests"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-audio"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-freetype"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-image"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-bullet"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-controllers"/>\r
+ <classpathentry combineaccessrules="false" exported="true" kind="src" path="/gdx-controllers-android"/>\r
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>\r
+ <classpathentry kind="output" path="bin/classes"/>\r
+</classpath>\r
\r
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;\r
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;\r
+import com.badlogic.gdx.tests.GleedTest;\r
+import com.badlogic.gdx.tests.TideMapAssetManagerTest;\r
+import com.badlogic.gdx.tests.TideMapDirectLoaderTest;\r
+import com.badlogic.gdx.tests.TiledMapAssetManagerTest;\r
+import com.badlogic.gdx.tests.TiledMapDirectLoaderTest;\r
import com.badlogic.gdx.tests.bench.TiledMapBench;\r
import com.badlogic.gdx.tests.utils.GdxTest;\r
import com.badlogic.gdx.utils.SharedLibraryLoader;\r
new SharedLibraryLoader("../../extensions/gdx-controllers/gdx-controllers-desktop/libs/gdx-controllers-desktop-natives.jar").load("gdx-controllers-desktop");\r
new SharedLibraryLoader("../../gdx/libs/gdx-natives.jar").load("gdx");\r
\r
- GdxTest test = new TiledMapBench();\r
+ GdxTest test = new TideMapDirectLoaderTest();\r
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();\r
config.useGL20 = test.needsGL20();\r
new LwjglApplication(test, config);\r