• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ChainShape类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ChainShape类属于com.badlogic.gdx.physics.box2d包,在下文中一共展示了ChainShape类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: createBody

import com.badlogic.gdx.physics.box2d.ChainShape; //导入依赖的package包/类
@Override
protected Body createBody(final Box2DService box2d) {
    final BodyDef bodyDef = new BodyDef();
    bodyDef.type = BodyType.StaticBody;
    bodyDef.fixedRotation = true;

    final ChainShape shape = new ChainShape();
    final float w = Box2DUtil.WIDTH * 2f / 5f, h = Box2DUtil.HEIGHT * 2f / 5f;
    shape.createLoop(new float[] { -w, -h, -w, h, w, h, w, -h });
    final FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.restitution = 0.9f;
    fixtureDef.friction = 0.2f;
    fixtureDef.shape = shape;
    fixtureDef.filter.categoryBits = Box2DUtil.CAT_BOUNDS;
    fixtureDef.filter.maskBits = Box2DUtil.MASK_BLOCK;
    final Body body = box2d.getWorld().createBody(bodyDef);
    body.createFixture(fixtureDef);
    return body;
}
 
开发者ID:BialJam,项目名称:M-M,代码行数:20,代码来源:BoundsEntity.java


示例3: 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


示例4: 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


示例5: createPhysicsWorld

import com.badlogic.gdx.physics.box2d.ChainShape; //导入依赖的package包/类
private void createPhysicsWorld() {

		world = new World(new Vector2(0, 0), true);
		
		float halfWidth = viewportWidth / 2f;
		ChainShape chainShape = new ChainShape();
		chainShape.createLoop(new Vector2[] {
				new Vector2(-halfWidth, 0f),
				new Vector2(halfWidth, 0f),
				new Vector2(halfWidth, viewportHeight),
				new Vector2(-halfWidth, viewportHeight) });
		BodyDef chainBodyDef = new BodyDef();
		chainBodyDef.type = BodyType.StaticBody;
		groundBody = world.createBody(chainBodyDef);
		groundBody.createFixture(chainShape, 0);
		chainShape.dispose();
		createBoxes();
	}
 
开发者ID:libgdx,项目名称:box2dlights,代码行数:19,代码来源:Box2dLightTest.java


示例6: createScreenBox

import com.badlogic.gdx.physics.box2d.ChainShape; //导入依赖的package包/类
public Body createScreenBox(final Rectangle rect) {
    ChainShape shape = new ChainShape();
    shape.createLoop(new Vector2[]{
            new Vector2(rect.x, rect.y).scl(1 / Box2dObject.RADIO),
            new Vector2(rect.x + rect.width, rect.y).scl(1 / Box2dObject.RADIO),
            new Vector2(rect.x + rect.width, rect.y + rect.height).scl(1 / Box2dObject.RADIO),
            new Vector2(rect.x, rect.y + rect.height).scl(1 / Box2dObject.RADIO),
    });

    final FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.isSensor = false;
    fixtureDef.shape = shape;

    BodyDef bodyDef = new BodyDef();
    bodyDef.bullet = false;
    bodyDef.type = BodyType.StaticBody;
    bodyDef.linearDamping = 0f;

    Body body = PhysicalWorld.WORLD.createBody(bodyDef);
    body.createFixture(fixtureDef);
    shape.dispose();
    return body;
}
 
开发者ID:lycying,项目名称:c2d-engine,代码行数:24,代码来源:Box2dStage.java


示例7: createShape

import com.badlogic.gdx.physics.box2d.ChainShape; //导入依赖的package包/类
/**
 * Creates the shape.
 */
@Override
public void createShape()
{
	shape = new ChainShape();
	fixtureDef.shape = shape;
	int length = _vertices.size;
	Vector2[] v = new Vector2[length];
	for(int i = 0; i < length; i++)
	{
		v[i] = new Vector2(_vertices.get(i)[0]/B2FlxB.RATIO, _vertices.get(i)[1]/B2FlxB.RATIO);
	}
	if(_loop)
		((ChainShape)shape).createLoop(v);
	else
	{
		((ChainShape)shape).createChain(v);
		// Add ghost edges
		if(_prevVertex != null)
			((ChainShape)shape).setPrevVertex(_prevVertex);
		if(_nextVertex != null)
			((ChainShape)shape).setNextVertex(_nextVertex);			
	}
}
 
开发者ID:flixel-gdx,项目名称:flixel-gdx-box2d,代码行数:27,代码来源:B2FlxChain.java


示例8: 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


示例9: drawBorder

import com.badlogic.gdx.physics.box2d.ChainShape; //导入依赖的package包/类
@Override
public void drawBorder(Border border, Batch batch, Color parentColor) {
    Shape shape = border.getShape();
    if (shape instanceof ChainShape) {
        Graphics.drawChain(border.getVertexes(), new Color(0.1f, 1, 0.5f, 0.75f), 0.2f);
    }

}
 
开发者ID:delphikettle,项目名称:libgdxGP,代码行数:9,代码来源:BorderDrawerSet.java


示例10: 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


示例11: 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


示例12: 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


示例13: 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


示例14: 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


示例15: Bounds

import com.badlogic.gdx.physics.box2d.ChainShape; //导入依赖的package包/类
public Bounds (World world, float hWidth, float hHeight) {
	bodyDef = new BodyDef();
	bodyDef.type = BodyType.StaticBody;
	
	body = world.createBody(bodyDef);
	ChainShape shape = new ChainShape();
	Vector2[] vertices = {new Vector2(-hWidth, -hHeight), new Vector2(-hWidth, hHeight), new Vector2(hWidth, hHeight), new Vector2(hWidth, -hHeight)};
	shape.createLoop(vertices);
	body.createFixture(shape, 0);
	
	shape.dispose();
	
	body.setUserData("bounds");
}
 
开发者ID:mcprog,项目名称:ragnar,代码行数:15,代码来源:Bounds.java


示例16: Piece

import com.badlogic.gdx.physics.box2d.ChainShape; //导入依赖的package包/类
public Piece (float radius, BodyType type, boolean isComposite) {
		ChainShape shape = new ChainShape();
//		ArrayList<Vector2> vectors = createArc(0, 0, radius, 180, 360, 0.07f, false);
//		vectors.add(new Vector2(vectors.get(vectors.size() - 1).x - 1, vectors.get(vectors.size() - 1).y));
//		vectors.add(0, new Vector2(vectors.get(0).x+1, vectors.get(0).y));
//		vectors.addAll(createArc(0, 0, radius-1, 0, -180, 0.07f, true));
//		Vector2[] finalVectors = new Vector2[vectors.size()];
//		((ChainShape)shape).createLoop(vectors.toArray(finalVectors));
//		vectors.clear();
//		finalVectors = null;
		this.shape = shape;
		this.pos = new Vector2();
		this.type = type;
	}
 
开发者ID:omgware,项目名称:fluid-simulator-v2,代码行数:15,代码来源:Piece.java


示例17: FixtureSerializer

import com.badlogic.gdx.physics.box2d.ChainShape; //导入依赖的package包/类
public FixtureSerializer(RubeScene scene, Json json)
{		
	this.scene = scene;
	chainShapeSerializer	= new ChainShapeSerializer();
	
	json.setSerializer(PolygonShape.class, new PolygonShapeSerializer());
	json.setSerializer(EdgeShape.class, new EdgeShapeSerializer());
	json.setSerializer(CircleShape.class, new CircleShapeSerializer());
	json.setSerializer(ChainShape.class, chainShapeSerializer);
}
 
开发者ID:tescott,项目名称:RubeLoader,代码行数:11,代码来源:FixtureSerializer.java


示例18: 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


示例19: randomCircleBody

import com.badlogic.gdx.physics.box2d.ChainShape; //导入依赖的package包/类
public static Body randomCircleBody(World world,Vector2 position,float dX,float dY,float minY,float maxY,int randomness){	
	//TODO: Should use a logger class here
	if (360%dX != 0) System.out.println("Creating random planet: dx must be multiple of 360");
	
	assert(360%dX == 0); // must be multiple of 360
	int steps = (int) (360 / dX)-1;
	Random rand = new Random();
	float prevElevation = (minY + maxY) / 2;
	
	boolean randomModeToggle = false;
	ArrayList<Vector2> verts = new ArrayList<Vector2>();
	
	for (int x = 1; x < steps; x++){
		Vector2 h = new Vector2();
		if (randomModeToggle)
			h.set(0,rand.nextFloat() * (maxY - minY) + minY);
		else
			h.set(0,getRandomElevation(prevElevation,dY,minY,maxY));
		
		if (randomness!=0){
			if (x%randomness == 0){
				randomModeToggle = !randomModeToggle;
			}
		}
		
		prevElevation = h.y;
		h.rotate(x * dX);
		verts.add(h);
	}
	
	ChainShape shape = new ChainShape();
	float[] fVerts = new float[verts.size() * 2];
	for (int x=0; x < verts.size(); x++){
		fVerts[x*2] = verts.get(x).x;
		fVerts[(x*2) + 1] = verts.get(x).y;
	}
	shape.createLoop(fVerts);

	FixtureDef fd = new FixtureDef();
	fd.density = 10;
	fd.friction = 10;
	fd.restitution = 0f;
	fd.shape = shape;
	
	BodyDef bd = new BodyDef();
	bd.type = BodyDef.BodyType.StaticBody;
	bd.position.set(position);
	
	Body body = world.createBody(bd);
	body.createFixture(fd);
	return body;
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:53,代码来源:Box2dHelper.java


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Section类代码示例发布时间:2022-05-21
下一篇:
Java HibernateTemplate类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap