當前位置: 首頁>>代碼示例>>Java>>正文


Java TiledMapTileLayer.getOpacity方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.maps.tiled.TiledMapTileLayer.getOpacity方法的典型用法代碼示例。如果您正苦於以下問題:Java TiledMapTileLayer.getOpacity方法的具體用法?Java TiledMapTileLayer.getOpacity怎麽用?Java TiledMapTileLayer.getOpacity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.maps.tiled.TiledMapTileLayer的用法示例。


在下文中一共展示了TiledMapTileLayer.getOpacity方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateCollisionMap

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
/**
 * <p>
 * Creates and returns a new {@link TerrainCollisionMap} from the given map.
 * If the map is not a valid Möbius map, the behaviour is undefined.
 * </p>
 * 
 * @param map
 *        The map from which to create a TerrainCollisionMap.
 * @return
 */
public static TerrainCollisionMap generateCollisionMap(TiledMap map, TiledMap mirrorMap) {
	TerrainCollisionMap retVal = null;

	MapLayers layers = map.getLayers();
	MapLayers mirrorLayers = mirrorMap.getLayers();

	TiledMapTileLayer egLayer = (TiledMapTileLayer) layers.get(0);
	HashMap<TiledMapTileLayer, PlatformManipulationHandler> platformLayers = new HashMap<TiledMapTileLayer, PlatformManipulationHandler>();

	ArrayList<Integer> collisionArray = null;

	for (int i = 0; i < layers.getCount(); i++) {
		TiledMapTileLayer origLayer = (TiledMapTileLayer) layers.get(i);
		TiledMapTileLayer mirrorLayer = (TiledMapTileLayer) mirrorLayers.get(i);

		if ((LevelEntityFactory.isSolidLayer(origLayer) && LevelEntityFactory.isSolidLayer(mirrorLayer))
				|| (LevelEntityFactory.isInteractableLayer(origLayer) && LevelEntityFactory
						.isInteractableLayer(mirrorLayer))) {
			if (collisionArray == null) {
				collisionArray = generateCollisionArray(origLayer, mirrorLayer);
			} else {
				if (origLayer.getOpacity() >= WorldConstants.GLOBAL_SOLID_OPACITY_THRESHOLD) {
					collisionArray = accumulateCollisionArray(collisionArray, origLayer, mirrorLayer);
				}
			}

			if (LevelEntityFactory.isInteractableLayer(origLayer)) {
				PlatformManipulationHandler handler = null;
				ArrayList<TerrainMapTileCoordinate> tileCoords = generatePlatformTileCoordinateArray(origLayer,
						mirrorLayer);

				InteractableLayerTypes layerType = LevelEntityFactory.getInteractableLayerType(origLayer);

				if (layerType.equals(InteractableLayerTypes.DX) || layerType.equals(InteractableLayerTypes.DY)) {
					handler = new MovingPlatformManipulationHandler(collisionArray, tileCoords,
							layerType.equals(InteractableLayerTypes.DX),
							layerType.equals(InteractableLayerTypes.DY));
				} else if (layerType.equals(InteractableLayerTypes.FADABLE)) {
					float opacity = origLayer.getOpacity();
					handler = new FadableLayerManipulationHandler(collisionArray, tileCoords,
							(opacity >= WorldConstants.GLOBAL_SOLID_OPACITY_THRESHOLD));
				}

				if (handler == null) {
					throw new GdxRuntimeException("Trying to create handler for invalid platform type.");
				} else {
					platformLayers.put(origLayer, handler);
					platformLayers.put(mirrorLayer, handler);
				}
			}
		}
	}

	retVal = new TerrainCollisionMap(egLayer, platformLayers, collisionArray);

	return retVal;
}
 
開發者ID:UoLCompSoc,項目名稱:mobius,代碼行數:68,代碼來源:TerrainCollisionMap.java

示例2: generateInteractablePlatformEntity

import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; //導入方法依賴的package包/類
protected Entity generateInteractablePlatformEntity(TiledMapTileLayer layer, boolean mirrored, float xOffset,
		float yOffset) {
	Entity e = world.createEntity();

	MapProperties properties = layer.getProperties();

	Rectangle platformRect = calculatePlatformRect(layer);
	if (platformRect == null) {
		Gdx.app.debug("LOAD_LEVEL", "Couldn't create platform rect for layer " + layer);
		return null;
	}

	Texture texture = null;

	int platSize = 0;

	PlatformSpriteOrientation orientation = PlatformSpriteOrientation.NONE;

	if (platformRect.height == 1.0f) { // if height is 1 tile
		texture = generateHorizontalPlatformTexture((int) platformRect.width);
		platSize = (int) platformRect.width;
		orientation = PlatformSpriteOrientation.HORIZONTAL;
	} else if (platformRect.width == 1.0f) {
		texture = generateVerticalPlatformTexture((int) platformRect.height);
		platSize = (int) platformRect.height;
		orientation = PlatformSpriteOrientation.VERTICAL;
	}

	Position position = world.createComponent(Position.class);
	position.position.x = platformRect.x + xOffset;
	position.position.y = platformRect.y + yOffset;

	PlatformSprite platformSprite = world.createComponent(PlatformSprite.class);
	platformSprite.setTexture(texture);
	platformSprite.mirrored = mirrored;
	platformSprite.spriteWidth = texture.getWidth();
	platformSprite.spriteHeight = texture.getHeight();
	platformSprite.size = platSize;
	platformSprite.orientation = orientation;
	platformSprite.rectangle = new Rectangle(platformRect);
	platformSprite.rectangle.width *= PLATFORM_TILE_WIDTH;
	platformSprite.rectangle.height *= PLATFORM_TILE_HEIGHT;

	e.addComponent(position);
	e.addComponent(platformSprite);
	e.addComponent(world.createComponent(PlatformInputListener.class));

	if (properties.get("dx") != null) {
		DxLayer dxLayer = world.createComponent(DxLayer.class);
		dxLayer.fromTiledProperties(properties);
		dxLayer.layer = layer;

		e.addComponent(dxLayer);
	} else if (properties.get("dy") != null) {
		DyLayer dyLayer = world.createComponent(DyLayer.class);
		dyLayer.fromTiledProperties(properties);
		dyLayer.layer = layer;

		e.addComponent(dyLayer);
	} else if (properties.get("minOpacity") != null) {
		Opacity opacity = world.createComponent(Opacity.class);
		opacity.opacity = layer.getOpacity();

		FadableLayer fadableLayer = world.createComponent(FadableLayer.class);
		fadableLayer.layer = layer;
		fadableLayer.setupOpacity(opacity, layer.getOpacity(), properties);

		e.addComponent(opacity);
		e.addComponent(fadableLayer);
	}

	Solid solid = world.createComponent(Solid.class);
	solid.boundingBox = platformSprite.rectangle;
	solid.invertedGravity = false;
	solid.weight = 100.0f;

	e.addToWorld();
	e.disable();
	return e;
}
 
開發者ID:UoLCompSoc,項目名稱:mobius,代碼行數:81,代碼來源:LevelEntityFactory.java


注:本文中的com.badlogic.gdx.maps.tiled.TiledMapTileLayer.getOpacity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。