当前位置: 首页>>代码示例>>Java>>正文


Java PolylineMapObject类代码示例

本文整理汇总了Java中com.badlogic.gdx.maps.objects.PolylineMapObject的典型用法代码示例。如果您正苦于以下问题:Java PolylineMapObject类的具体用法?Java PolylineMapObject怎么用?Java PolylineMapObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PolylineMapObject类属于com.badlogic.gdx.maps.objects包,在下文中一共展示了PolylineMapObject类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processFreeBodies

import com.badlogic.gdx.maps.objects.PolylineMapObject; //导入依赖的package包/类
private void processFreeBodies(Array<MapObject> bodies) {
    for (MapObject object : bodies) {
        FixtureBodyDefinition fixtureBodyDefinition;
        if (object instanceof RectangleMapObject) {
            fixtureBodyDefinition = TiledUtils.createRectangleFixtureBodyDef((RectangleMapObject)object);
        } else if (object instanceof CircleMapObject) {
            fixtureBodyDefinition = TiledUtils.createCircleFixtureBodyDef((CircleMapObject)object);
        } else if (object instanceof EllipseMapObject) {
            fixtureBodyDefinition = TiledUtils.createEllipseFixtureBodyDef((EllipseMapObject)object);
        } else if (object instanceof PolylineMapObject || object instanceof PolygonMapObject) {
            fixtureBodyDefinition = TiledUtils.createPolyFixtureBodyDef(object);
        } else {
            throw new InvalidConfigException(filename, "Unknown MapObject type");
        }

        freeBodyDefinitions.add(fixtureBodyDefinition);
    }
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:19,代码来源:TiledMapLevelLoadable.java

示例2: getFixtureDefFromBodySkeleton

import com.badlogic.gdx.maps.objects.PolylineMapObject; //导入依赖的package包/类
public static FixtureDef getFixtureDefFromBodySkeleton(MapObject object) {
    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.density = 1;
    fixtureDef.friction = 0;
    fixtureDef.restitution = 0;

    Shape shape = null;
    if (object instanceof TextureMapObject) {
        shape = getTextureMapShape(object);
    } else if (object instanceof RectangleMapObject) {
        shape = getRectangleShape(object);
    } else if (object instanceof CircleMapObject) {
        shape = getCircleShape(object);
    } else if (object instanceof EllipseMapObject) {
        shape = getEllipseShape(object);
    } else if (object instanceof PolygonMapObject) {
        shape = getPolygonShape(object);
    } else if (object instanceof PolylineMapObject) {
        shape = getPolylineShape(object);
    }

    fixtureDef.shape = shape;

    return fixtureDef;
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:26,代码来源:TiledUtils.java

示例3: getPolyline

import com.badlogic.gdx.maps.objects.PolylineMapObject; //导入依赖的package包/类
private static Shape getPolyline(PolylineMapObject object) {
	float[] vertices = object.getPolyline().getTransformedVertices();
	Vector2[] worldVertices = new Vector2[vertices.length / 2];
	
	for(int i = 0; i < vertices.length / 2; ++i){
		Vector2 vector = new Vector2();
		vector.x = vertices[i * 2];
		vector.y = vertices[i * 2 + 1];
		
		worldVertices[i] = Pixels.toMeters(new Vector2(vector));
	}
	
	ChainShape shape = new ChainShape();
	shape.createChain(worldVertices);
	return shape;
}
 
开发者ID:Portals,项目名称:DropTheCube-LD32,代码行数:17,代码来源:Box2DUtils.java

示例4: getPolylineShape

import com.badlogic.gdx.maps.objects.PolylineMapObject; //导入依赖的package包/类
private static Shape getPolylineShape(MapObject object) {
    Polyline polyline = ((PolylineMapObject)object).getPolyline();
    float[] vertices = polyline.getTransformedVertices();
    for (int i = 0; i < vertices.length; i++) {
        vertices[i] *= MainCamera.getInstance().getTileMapScale();
    }

    ChainShape shape = new ChainShape();
    shape.createChain(vertices);

    return shape;
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:13,代码来源:TiledUtils.java

示例5: createBodies

import com.badlogic.gdx.maps.objects.PolylineMapObject; //导入依赖的package包/类
/**
 * 
 * @param world
 * @param map
 */
public void createBodies(ArrayList<Entity> entities, World world, TiledMap map){
	MapObjects objects;
	
	objects = map.getLayers().get("ground").getObjects();
	for(MapObject object : objects){
		if(object instanceof RectangleMapObject){
			createRectangle(world, (RectangleMapObject) object, 0.5f, 0.4f, 0.6f);
		} else if(object instanceof PolygonMapObject){
			createPolygon(world, (PolygonMapObject) object, 0.5f, 0.4f, 0.6f);
		} else if(object instanceof PolylineMapObject){
			createPolyline(world, (PolylineMapObject) object, 0.5f, 0.4f, 0.6f);
		} else if(object instanceof EllipseMapObject){
			createEllipse(world, (EllipseMapObject) object, 0.5f, 0.4f, 0.6f);
		} else{
			Gdx.app.error("Error", "Invalid map object");
		}
	}
	
	/*
	objects = map.getLayers().get("dynamic").getObjects();
	for(MapObject object : objects){
		RectangleMapObject entity = (RectangleMapObject) object;
		Rectangle position = entity.getRectangle();
		entities.add(new Box(world, new Vector2(position.x / SupaBox.PPM, position.y / SupaBox.PPM), new Vector2(0f, 0f), 1f, 1f));
	}
	*/
}
 
开发者ID:ryanshappell,项目名称:SupaBax,代码行数:33,代码来源:BodyBuilder.java

示例6: createPolyline

import com.badlogic.gdx.maps.objects.PolylineMapObject; //导入依赖的package包/类
/**
 * 
 * @param world
 * @param polylineObject
 * @param density
 * @param friction
 * @param restitution
 */
private void createPolyline(World world, PolylineMapObject polylineObject, float density, float friction, float restitution){
	Polyline polyline = polylineObject.getPolyline();
	ChainShape shape = new ChainShape();
	float[] vertices = polyline.getTransformedVertices();
	float[] worldVertices = new float[vertices.length];
	
	for(int i = 0; i < vertices.length; i++){
		worldVertices[i] = vertices[i] / SupaBox.PPM;
	}
	
	shape.createChain(worldVertices);
	
	BodyDef bodyDef = new BodyDef();
	bodyDef.type = BodyType.StaticBody;
	
	Body body = world.createBody(bodyDef);
	
	FixtureDef fixtureDef = new FixtureDef();
	fixtureDef.shape = shape;
	fixtureDef.density = density;
	fixtureDef.friction = friction;
	fixtureDef.restitution = restitution;
	
	body.createFixture(fixtureDef);
	
	shape.dispose();
}
 
开发者ID:ryanshappell,项目名称:SupaBax,代码行数:36,代码来源:BodyBuilder.java

示例7: getPolyline

import com.badlogic.gdx.maps.objects.PolylineMapObject; //导入依赖的package包/类
private Shape getPolyline(PolylineMapObject polylineObject) {
	float[] vertices = polylineObject.getPolyline().getTransformedVertices();
	Vector2[] worldVertices = new Vector2[vertices.length / 2];
	
	for (int i = 0; i < vertices.length / 2; ++i) {
	    worldVertices[i] = new Vector2();
	    worldVertices[i].x = vertices[i * 2] / GameWorld.units;
	    worldVertices[i].y = vertices[i * 2 + 1] / GameWorld.units;
	}
	
	ChainShape chain = new ChainShape(); 
	chain.createChain(worldVertices);
	return chain;
}
 
开发者ID:programacion2VideojuegosUM2015,项目名称:practicos,代码行数:15,代码来源:GeneradorNivel.java

示例8: getPolyline

import com.badlogic.gdx.maps.objects.PolylineMapObject; //导入依赖的package包/类
private Shape getPolyline(PolylineMapObject polylineObject) {
	float[] vertices = polylineObject.getPolyline().getTransformedVertices();
	Vector2[] worldVertices = new Vector2[vertices.length / 2];
	
	for (int i = 0; i < vertices.length / 2; ++i) {
	    worldVertices[i] = new Vector2();
	    worldVertices[i].x = vertices[i * 2] / units;
	    worldVertices[i].y = vertices[i * 2 + 1] / units;
	}
	
	ChainShape chain = new ChainShape(); 
	chain.createChain(worldVertices);
	return chain;
}
 
开发者ID:saltares,项目名称:sioncore,代码行数:15,代码来源:MapBodyManager.java

示例9: getPolyline

import com.badlogic.gdx.maps.objects.PolylineMapObject; //导入依赖的package包/类
private Shape getPolyline(PolylineMapObject polylineObject) {
	float[] vertices = polylineObject.getPolyline().getVertices(); // Changed
	Vector2[] worldVertices = new Vector2[vertices.length / 2];

	for (int i = 0; i < vertices.length / 2; ++i) {
		worldVertices[i] = new Vector2();
		worldVertices[i].x = vertices[i * 2] * m_units;
		worldVertices[i].y = vertices[i * 2 + 1] * m_units;
	}

	ChainShape chain = new ChainShape();
	chain.createChain(worldVertices);
	return chain;
}
 
开发者ID:LostCodeStudios,项目名称:JavaLib,代码行数:15,代码来源:MapBodyManager.java

示例10: onInit

import com.badlogic.gdx.maps.objects.PolylineMapObject; //导入依赖的package包/类
/**
 * Initialisiert den NPC.
 * Erstellt eine Liste aller Wegpunkte.
 */
@Override
public void onInit()
{
    super.onInit();

    float[] vertices;

    if (rawObject instanceof PolylineMapObject)
    {
        PolylineMapObject polyline = (PolylineMapObject) rawObject;
        loop = false;

        vertices = polyline.getPolyline().getTransformedVertices();
    }
    else if (rawObject instanceof PolygonMapObject)
    {
        PolygonMapObject polygon = (PolygonMapObject) rawObject;
        loop = true;

        vertices = polygon.getPolygon().getTransformedVertices();
    }
    else
    {
        Gdx.app.log("WARNING", objectId + ": MapObject must be Polyline or Polygon.");

        worldObjectManager.removeObject(this);

        return;
    }

    waypoints = new Vector2[vertices.length / 2];

    for (int i = 0; i < vertices.length / 2; i++)
    {
        waypoints[i] = new Vector2();
        waypoints[i].x = vertices[i * 2];
        waypoints[i].y = vertices[i * 2 + 1];
    }

    if (waypoints.length < 2)
    {
        Gdx.app.log("WARNING", objectId + ": Must have at least 2 Waypoints.");

        worldObjectManager.removeObject(this);

        return;
    }

    body = createCircleBody(waypoints[0].cpy(), 10);
    targetIndex = 1;
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:56,代码来源:WaypointNPC.java

示例11: crearColisiones

import com.badlogic.gdx.maps.objects.PolylineMapObject; //导入依赖的package包/类
private void crearColisiones() {
   	
Array<Body> slopes = new Array<Body>();
FixtureDef fixDef = new FixtureDef();
   	
	
MapObjects objects = cls.getObjects();
Iterator<MapObject> objectIt = objects.iterator();
		
while(objectIt.hasNext()) {
MapObject object = objectIt.next();
		
if (object instanceof TextureMapObject){
  continue;
}
		
Shape shape;
BodyDef bodyDef = new BodyDef();
bodyDef.type = BodyDef.BodyType.StaticBody;
		
if (object instanceof RectangleMapObject) {
    RectangleMapObject rectangle = (RectangleMapObject)object;
    shape = getRectangle(rectangle);
}
else if (object instanceof PolygonMapObject) {
	shape = getPolygon((PolygonMapObject)object);
}
else if (object instanceof PolylineMapObject) {
	shape = getPolyline((PolylineMapObject)object);
}
else if (object instanceof EllipseMapObject) {
	shape = getEllipse((EllipseMapObject)object);
}
else if (object instanceof CircleMapObject) {
	shape = getCircle((CircleMapObject)object);
}
else {
	continue;
}
		
		
fixDef.shape = shape;
fixDef.filter.categoryBits = GameWorld.BIT_PARED;
  fixDef.filter.maskBits = GameWorld.BIT_JUGADOR | GameWorld.BIT_ENEMIGOS | GameWorld.BIT_SENSOR;
   		

Body suelo = GameWorld.mundo.createBody(bodyDef);
suelo.createFixture(fixDef).setUserData("cls");
		
slopes.add(suelo);
		
shape.dispose();
  }
}
 
开发者ID:programacion2VideojuegosUM2015,项目名称:practicos,代码行数:55,代码来源:GeneradorNivel.java

示例12: createPhysics

import com.badlogic.gdx.maps.objects.PolylineMapObject; //导入依赖的package包/类
/**
 * @param map map to be used to create the static bodies. 
 * @param layerName name of the layer that contains the shapes.
 */
public void createPhysics(Map map, String layerName) {
	MapLayer layer = map.getLayers().get(layerName);
	
	if (layer == null) {
		logger.error("layer " + layerName + " does not exist");
		return;
	}
	
	MapObjects objects = layer.getObjects();
	Iterator<MapObject> objectIt = objects.iterator();
		
	while(objectIt.hasNext()) {
		MapObject object = objectIt.next();
		
		if (object instanceof TextureMapObject){
			continue;
		}
		
		Shape shape;
		BodyDef bodyDef = new BodyDef();
		bodyDef.type = BodyDef.BodyType.StaticBody;
		
		if (object instanceof RectangleMapObject) {
			RectangleMapObject rectangle = (RectangleMapObject)object;
			shape = getRectangle(rectangle);
		}
		else if (object instanceof PolygonMapObject) {
			shape = getPolygon((PolygonMapObject)object);
		}
		else if (object instanceof PolylineMapObject) {
			shape = getPolyline((PolylineMapObject)object);
		}
		else if (object instanceof CircleMapObject) {
			shape = getCircle((CircleMapObject)object);
		}
		else {
			logger.error("non suported shape " + object);
			continue;
		}
		
		MapProperties properties = object.getProperties();
		String material = properties.get("material", "default", String.class);
		FixtureDef fixtureDef = materials.get(material);
		
		if (fixtureDef == null) {
			logger.error("material does not exist " + material + " using default");
			fixtureDef = materials.get("default");
		}
		
		fixtureDef.shape = shape;
		fixtureDef.filter.categoryBits = Env.game.getCategoryBitsManager().getCategoryBits("level");

		Body body = world.createBody(bodyDef);
		body.createFixture(fixtureDef);
		
		bodies.add(body);
		
		fixtureDef.shape = null;
		shape.dispose();
	}
}
 
开发者ID:saltares,项目名称:sioncore,代码行数:66,代码来源:MapBodyManager.java


注:本文中的com.badlogic.gdx.maps.objects.PolylineMapObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。