OSDN Git Service

Add BlendMode to TiledMapTile interface.
authorJustin Shapcott <support@mobidevelop.com>
Sat, 16 Feb 2013 16:31:56 +0000 (09:31 -0700)
committerJustin Shapcott <support@mobidevelop.com>
Sat, 16 Feb 2013 16:31:56 +0000 (09:31 -0700)
BlendMode allows the renderer to potentially optimize the rendering of
a map by batching tiles with the same BlendMode together. This will be
particularly helpful in cases where the map has a large number of
non-blended tiles.

gdx/src/com/badlogic/gdx/maps/tiled/TiledMapTile.java
gdx/src/com/badlogic/gdx/maps/tiled/tiles/StaticTiledMapTile.java

index ff1e50c..622a85d 100644 (file)
@@ -9,6 +9,23 @@ import com.badlogic.gdx.maps.MapProperties;
  */
 public interface TiledMapTile {
 
+       public enum BlendMode {
+               NONE,
+               ALPHA
+       }
+
+       /**
+        * @return the {@link BlendMode} to use for rendering the tile
+        */     
+       public BlendMode getBlendMode();
+       
+       /**
+        * Sets the {@link BlendMode} to use for rendering the tile
+        * 
+        * @param blendMode the blend mode to use for rendering the tile
+        */
+       public void setBlendMode(BlendMode blendMode);
+       
        /**
         * @return texture region used to render the tile
         */
index 9486296..c9f783e 100644 (file)
@@ -9,15 +9,30 @@ import com.badlogic.gdx.maps.tiled.TiledMapTile;
  */
 public class StaticTiledMapTile implements TiledMapTile {
 
+       private BlendMode blendMode = BlendMode.ALPHA;
+       
        private MapProperties properties;
        
        private TextureRegion textureRegion;    
 
+       @Override
+       public BlendMode getBlendMode () {
+               return blendMode;
+       }
+
+       @Override
+       public void setBlendMode (BlendMode blendMode) {
+               this.blendMode = blendMode;
+       }       
+       
        /**
         * @return tile's properties set
         */
        @Override
        public MapProperties getProperties() {
+               if (properties == null) {
+                       properties = new MapProperties();
+               }
                return properties;
        }
 
@@ -44,7 +59,7 @@ public class StaticTiledMapTile implements TiledMapTile {
         * @param copy
         */
        public StaticTiledMapTile(StaticTiledMapTile copy) {
-               this.properties.putAll(copy.properties);
+               getProperties().putAll(copy.properties);
                this.textureRegion = copy.textureRegion;
        }