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


Java ChainShape.createChain方法代码示例

本文整理汇总了Java中com.badlogic.gdx.physics.box2d.ChainShape.createChain方法的典型用法代码示例。如果您正苦于以下问题:Java ChainShape.createChain方法的具体用法?Java ChainShape.createChain怎么用?Java ChainShape.createChain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.physics.box2d.ChainShape的用法示例。


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

示例1: createPolyline

import com.badlogic.gdx.physics.box2d.ChainShape; //导入方法依赖的package包/类
/**
 * Erzeugt aus einem PolylineMapObject ein ChainShape.
 *
 * @param polyObject das MapObject
 * @return die entsprechende Form
 */
public static ChainShape createPolyline(PolylineMapObject polyObject)
{
    float[] vertices = polyObject.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] * Physics.MPP;
        worldVertices[i].y = vertices[i * 2 + 1] * Physics.MPP;
    }

    ChainShape chain = new ChainShape();
    chain.createChain(worldVertices);

    return chain;
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:24,代码来源:PhysicsTileMapBuilder.java

示例2: getPolyline

import com.badlogic.gdx.physics.box2d.ChainShape; //导入方法依赖的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

示例3: create

import com.badlogic.gdx.physics.box2d.ChainShape; //导入方法依赖的package包/类
public void create(){
	init = true;
	bdef.type = BodyType.StaticBody;
	bdef.position.set(x, y);
	
	ChainShape cs = new ChainShape();
	Vector2[] v = new Vector2[5];
	
	v[0] = new Vector2(-TILE_SIZE / 2 / PPM, -TILE_SIZE / 2 / PPM);
	v[1] = new Vector2(-TILE_SIZE / 2 / PPM, TILE_SIZE / 2 / PPM);
	v[2] = new Vector2(TILE_SIZE / 2 / PPM, TILE_SIZE / 2 / PPM);
	v[3] = new Vector2(TILE_SIZE / 2 / PPM, -TILE_SIZE / 2 / PPM);
	v[4] = new Vector2(-Vars.TILE_SIZE / 2 / Vars.PPM, -Vars.TILE_SIZE / 2 / Vars.PPM);
	cs.createChain(v);
	
	fdef.friction = .25f;
	fdef.shape = cs;
	fdef.filter.categoryBits = Vars.BIT_GROUND;
	fdef.filter.maskBits = Vars.BIT_LAYER1 | Vars.BIT_PLAYER_LAYER | Vars.BIT_LAYER3 | Vars.BIT_BATTLE;
	fdef.isSensor = false;
	body = world.createBody(bdef);
	body.createFixture(fdef).setUserData("ground");
	body.setUserData(this);
}
 
开发者ID:JayKEm,项目名称:Aftamath,代码行数:25,代码来源:Ground.java

示例4: getPolylineShape

import com.badlogic.gdx.physics.box2d.ChainShape; //导入方法依赖的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: createBlocks

import com.badlogic.gdx.physics.box2d.ChainShape; //导入方法依赖的package包/类
/**
 * Creates box2d bodies for all non-null tiles
 * in the specified layer and assigns the specified
 * category bits.
 *
 * @param layer the layer being read
 * @param bits  category bits assigned to fixtures
 */
private void createBlocks(TiledMapTileLayer layer, short bits) {

    // tile size
    float ts = layer.getTileWidth();

    // go through all cells in layer
    for (int row = 0; row < layer.getHeight(); row++) {
        for (int col = 0; col < layer.getWidth(); col++) {

            // get cell
            Cell cell = layer.getCell(col, row);

            // check that there is a cell
            if (cell == null) continue;
            if (cell.getTile() == null) continue;

            // create body from cell
            BodyDef bdef = new BodyDef();
            bdef.type = BodyType.StaticBody;
            bdef.position.set((col + 0.5f) * ts / PPM, (row + 0.5f) * ts / PPM);
            ChainShape cs = new ChainShape();
            Vector2[] v = new Vector2[3];
            v[0] = new Vector2(-ts / 2 / PPM, -ts / 2 / PPM);
            v[1] = new Vector2(-ts / 2 / PPM, ts / 2 / PPM);
            v[2] = new Vector2(ts / 2 / PPM, ts / 2 / PPM);
            cs.createChain(v);
            FixtureDef fd = new FixtureDef();
            fd.friction = 0;
            fd.shape = cs;
            fd.filter.categoryBits = bits;
            fd.filter.maskBits = B2DVars.BIT_PLAYER;
            world.createBody(bdef).createFixture(fd);
            cs.dispose();

        }
    }

}
 
开发者ID:awwong1,项目名称:BlockBunny,代码行数:47,代码来源:Play.java

示例6: Bounds

import com.badlogic.gdx.physics.box2d.ChainShape; //导入方法依赖的package包/类
public Bounds(World world) {
	
	BodyDef bodyDef = new BodyDef();
	FixtureDef fixtureDef = new FixtureDef();
	float groundPos = -2.5f;
	float topPos = 7.5f;
	
	// body definition
	bodyDef.type = BodyType.StaticBody;
	bodyDef.position.set(0, groundPos);

	// ground shape
	ChainShape groundShapeBottom = new ChainShape();
	ChainShape groundShapeTop = new ChainShape();
	
	/*
	groundShape.createChain(new Vector2[] {new Vector2(-10, groundPos), new Vector2(10,groundPos),
			new Vector2(10, 8.35f), new Vector2(-10,8.35f), new Vector2(-10,groundPos)});
	*/
	
	groundShapeBottom.createChain(new Vector2[] {new Vector2(-10, groundPos), new Vector2(10,groundPos)});
	groundShapeTop.createChain(new Vector2[] {new Vector2(-10, topPos), new Vector2(10,topPos)});

	// fixture definition
	fixtureDef.shape = groundShapeBottom;

	body = world.createBody(bodyDef);
	fixture = body.createFixture(fixtureDef);
	
	// fixture definition
	fixtureDef.shape = groundShapeTop;

	body = world.createBody(bodyDef);
	fixture = body.createFixture(fixtureDef);
	
	groundShapeTop.dispose();
	groundShapeBottom.dispose();
}
 
开发者ID:CODA-Masters,项目名称:Pong-Tutorial,代码行数:39,代码来源:Bounds.java

示例7: createPolyline

import com.badlogic.gdx.physics.box2d.ChainShape; //导入方法依赖的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

示例8: getPolyline

import com.badlogic.gdx.physics.box2d.ChainShape; //导入方法依赖的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

示例9: getPolyline

import com.badlogic.gdx.physics.box2d.ChainShape; //导入方法依赖的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

示例10: getPolyline

import com.badlogic.gdx.physics.box2d.ChainShape; //导入方法依赖的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

示例11: shapePolyline

import com.badlogic.gdx.physics.box2d.ChainShape; //导入方法依赖的package包/类
public PhysixFixtureDef shapePolyline(List<Point> points) {
    ChainShape chainShape = new ChainShape();
    chainShape.createChain(system.toBox2D(points));
    this.shape = chainShape;
    return this;
}
 
开发者ID:GameDevWeek,项目名称:CodeBase,代码行数:7,代码来源:PhysixFixtureDef.java

示例12: createChainShape

import com.badlogic.gdx.physics.box2d.ChainShape; //导入方法依赖的package包/类
public static Shape createChainShape(Vector2[] vertices) {
	ChainShape chainShape = new ChainShape();
	chainShape.createChain(vertices);

	return chainShape;
}
 
开发者ID:Leakedbits,项目名称:Codelabs,代码行数:7,代码来源:Box2DFactory.java


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