OSDN Git Service

fixed smallish stuff
authorMario Zechner <contact@badlogicgames.com>
Tue, 19 Feb 2013 23:23:11 +0000 (00:23 +0100)
committerMario Zechner <contact@badlogicgames.com>
Tue, 19 Feb 2013 23:23:11 +0000 (00:23 +0100)
gdx/src/com/badlogic/gdx/maps/ImageResolver.java
gdx/src/com/badlogic/gdx/maps/tiled/TideMapLoader.java
gdx/src/com/badlogic/gdx/maps/tiled/TmxMapLoader.java
tests/gdx-tests-android/.classpath
tests/gdx-tests-lwjgl/src/com/badlogic/gdx/tests/lwjgl/LwjglDebugStarter.java

index 95e2ca9..0f14607 100755 (executable)
@@ -2,6 +2,8 @@ package com.badlogic.gdx.maps;
 \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
@@ -15,7 +17,7 @@ public interface ImageResolver {
         * @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
@@ -25,8 +27,8 @@ public interface ImageResolver {
                }\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
@@ -38,8 +40,21 @@ public interface ImageResolver {
                }\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
index d454fea..ff619e0 100644 (file)
@@ -155,7 +155,7 @@ public class TideMapLoader extends SynchronousAssetLoader<TiledMap, TideMapLoade
                        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.
@@ -170,8 +170,8 @@ public class TideMapLoader extends SynchronousAssetLoader<TiledMap, TideMapLoade
                        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) {
index 94a94b5..f9352ec 100644 (file)
@@ -205,13 +205,13 @@ public class TmxMapLoader extends SynchronousAssetLoader<TiledMap, TmxMapLoader.
                                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;
                        
index 2616471..738053d 100644 (file)
@@ -1,17 +1,16 @@
-<?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
index c9e15e5..de0026e 100644 (file)
@@ -18,6 +18,11 @@ package com.badlogic.gdx.tests.lwjgl;
 \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
@@ -31,7 +36,7 @@ public class LwjglDebugStarter {
                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