Home | History | Annotate | Download | only in objects
      1 /*******************************************************************************
      2  * Copyright 2011 See AUTHORS file.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *   http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  ******************************************************************************/
     16 
     17 package com.badlogic.gdx.maps.tiled.objects;
     18 
     19 import com.badlogic.gdx.graphics.g2d.TextureRegion;
     20 import com.badlogic.gdx.maps.MapObject;
     21 import com.badlogic.gdx.maps.objects.TextureMapObject;
     22 import com.badlogic.gdx.maps.tiled.TiledMapTile;
     23 import com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile;
     24 import com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile;
     25 
     26 /** A {@link MapObject} with a {@link TiledMapTile}. Can be both {@link StaticTiledMapTile} or {@link AnimatedTiledMapTile}. For
     27  * compatibility reasons, this extends {@link TextureMapObject}. Use {@link TiledMapTile#getTextureRegion()} instead of
     28  * {@link #getTextureRegion()}.
     29  * @author Daniel Holderbaum */
     30 public class TiledMapTileMapObject extends TextureMapObject {
     31 
     32 	private boolean flipHorizontally;
     33 	private boolean flipVertically;
     34 
     35 	private TiledMapTile tile;
     36 
     37 	public TiledMapTileMapObject (TiledMapTile tile, boolean flipHorizontally, boolean flipVertically) {
     38 		this.flipHorizontally = flipHorizontally;
     39 		this.flipVertically = flipVertically;
     40 		this.tile = tile;
     41 
     42 		TextureRegion textureRegion = new TextureRegion(tile.getTextureRegion());
     43 		textureRegion.flip(flipHorizontally, flipVertically);
     44 		setTextureRegion(textureRegion);
     45 	}
     46 
     47 	public boolean isFlipHorizontally () {
     48 		return flipHorizontally;
     49 	}
     50 
     51 	public void setFlipHorizontally (boolean flipHorizontally) {
     52 		this.flipHorizontally = flipHorizontally;
     53 	}
     54 
     55 	public boolean isFlipVertically () {
     56 		return flipVertically;
     57 	}
     58 
     59 	public void setFlipVertically (boolean flipVertically) {
     60 		this.flipVertically = flipVertically;
     61 	}
     62 
     63 	public TiledMapTile getTile () {
     64 		return tile;
     65 	}
     66 
     67 	public void setTile (TiledMapTile tile) {
     68 		this.tile = tile;
     69 	}
     70 
     71 }
     72