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


Java BodyType.KinematicBody方法代码示例

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


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

示例1: Food

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public Food(World world, float x, float y, int size, float toGive) {
	super(x, y);
	color = new Color((float) Math.random(), (float) Math.random(), (float) Math.random(), 1);
	outline = Advio.instance.darker(color);
	BodyDef bd = new BodyDef();
	bd.type = BodyType.KinematicBody;
	bd.position.set(x, y);
	CircleShape shape = new CircleShape();
	shape.setRadius(size);
	FixtureDef fd = new FixtureDef();
	fd.density = 0.1f;
	fd.shape = shape;
	fd.friction = 0.1f;
	// fd.filter.groupIndex = Advio.GROUP_BEINGS;
	body = world.createBody(bd);
	body.createFixture(fd).setUserData(new UserData("food").add("toGive", toGive));
	shape.dispose();
}
 
开发者ID:lvivtotoro,项目名称:advio,代码行数:19,代码来源:Food.java

示例2: PressurePlate

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public PressurePlate(Level l, World world, float x, float y, float weight, Block[] blocks) {
	super(x, y);
	this.level = l;
	BodyDef bd = new BodyDef();
	bd.type = BodyType.KinematicBody;
	bd.position.set(x, y);
	PolygonShape shape = new PolygonShape();
	shape.setAsBox(Block.size / 2, Block.size / 2);
	FixtureDef fd = new FixtureDef();
	fd.density = 0.0f;
	fd.shape = shape;
	fd.friction = 0.1f;
	fd.isSensor = true;
	this.blocks = new ArrayList<Block>(Arrays.asList(blocks));
	body = world.createBody(bd);
	body.createFixture(fd).setUserData(new UserData("plate").add("pressed", false).add("weight", weight));
	shape.dispose();
	this.world = world;
}
 
开发者ID:lvivtotoro,项目名称:advio,代码行数:20,代码来源:PressurePlate.java

示例3: AgarLogic

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public AgarLogic(Level l, World world, float x, float y) {
	super(x, y);
	this.level = l;
	BodyDef bd = new BodyDef();
	bd.type = BodyType.KinematicBody;
	bd.position.set(x, y);
	PolygonShape shape = new PolygonShape();
	shape.setAsBox(Block.size / 2, Block.size / 2);
	FixtureDef fd = new FixtureDef();
	fd.density = 0.0f;
	fd.shape = shape;
	fd.friction = 0.1f;
	fd.isSensor = true;
	body = world.createBody(bd);
	body.createFixture(fd).setUserData(new UserData("agariologic"));
	shape.dispose();
	this.world = world;
}
 
开发者ID:lvivtotoro,项目名称:advio,代码行数:19,代码来源:AgarLogic.java

示例4: Goal

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public Goal(World world, float x, float y) {
	super(x, y);
	BodyDef bd = new BodyDef();
	bd.type = BodyType.KinematicBody;
	bd.position.set(x, y);
	PolygonShape shape = new PolygonShape();
	shape.setAsBox(Block.size / 2, Block.size / 2);
	FixtureDef fd = new FixtureDef();
	fd.density = 0.1f;
	fd.shape = shape;
	fd.friction = 0.1f;
	fd.isSensor = true;
	// fd.filter.groupIndex = Advio.GROUP_SCENERY;
	body = world.createBody(bd);
	body.createFixture(fd).setUserData(new UserData("goal"));
	shape.dispose();
}
 
开发者ID:lvivtotoro,项目名称:advio,代码行数:18,代码来源:Goal.java

示例5: Enemy

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
Enemy (TextureRegion texture) {
	this.texture = texture;
	
	BodyDef squareD = new BodyDef();
	squareD.type = BodyType.KinematicBody;
	squareD.position.set((float) Math.random() * SCREEN_WIDTH, SCREEN_HEIGHT + 3.0f);
	//squareD.linearVelocity.set(0.0f, -((float) Math.random() * (SQUARE_MAX_SPEED - SQUARE_MIN_SPEED)) + SQUARE_MIN_SPEED);
	//squareD.angularVelocity = (SQUARE_MAX_SPEED + squareD.linearVelocity.y) * (Math.random() >= 0.5f ? 1 : -1);
	squareD.gravityScale = 0;
	body = world.createBody(squareD);
	
	FixtureDef squareFD = new FixtureDef();
	squareFD.shape = squareShape;
	//squareFD.density = 99999999;
	squareFD.friction = 0;
	squareFD.restitution = 1;
	squareFD.filter.categoryBits = CATEGORY_ENEMY;
	squareFD.filter.maskBits = MASK_ENEMY;
	body.createFixture(squareFD);
}
 
开发者ID:zozotintin,项目名称:Dodgy-Dot,代码行数:21,代码来源:GameScreen.java

示例6: create

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
@Override
public void create() {
	init = true;
	PolygonShape shape = new PolygonShape();
	shape.setAsBox((rw)/Vars.PPM, (rh)/Vars.PPM);

	bdef.position.set(x/Vars.PPM, y/Vars.PPM);
	bdef.type = BodyType.KinematicBody;
	fdef.shape = shape;
	
	fdef.isSensor = true;
	body = world.createBody(bdef);
	body.setUserData(this);
	fdef.filter.maskBits = (short) ( Vars.BIT_GROUND | Vars.BIT_BATTLE| Vars.BIT_LAYER1| Vars.BIT_PLAYER_LAYER| Vars.BIT_LAYER3);
	fdef.filter.categoryBits = (short) ( Vars.BIT_GROUND | Vars.BIT_BATTLE| Vars.BIT_LAYER1| Vars.BIT_PLAYER_LAYER| Vars.BIT_LAYER3);
	body.createFixture(fdef).setUserData(Vars.trimNumbers(ID));
	
	createCenter();
}
 
开发者ID:JayKEm,项目名称:Aftamath,代码行数:20,代码来源:Warp.java

示例7: create

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public void create(){
	init = true;
	//hitbox
	PolygonShape shape = new PolygonShape();
	shape.setAsBox((rw)/PPM, (rh)/PPM);
	
	bdef.position.set(x/PPM, y/PPM);
	bdef.type = BodyType.KinematicBody;
	fdef.shape = shape;
	body = world.createBody(bdef);
	body.setUserData(this);
	fdef.filter.maskBits = (short) (layer | Vars.BIT_GROUND | Vars.BIT_BATTLE);
	fdef.filter.categoryBits = layer;
	body.createFixture(fdef).setUserData(Vars.trimNumbers(ID));
	body.setMassData(mdat);
	
	createCenter();
	if(!main.exists(this)) main.addObject(this);
}
 
开发者ID:JayKEm,项目名称:Aftamath,代码行数:20,代码来源:Entity.java

示例8: create

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public void create(){
	init = true;
	bdef = new BodyDef();
	fdef = new FixtureDef();
	//hitbox
	setDirection(false);
	PolygonShape shape = new PolygonShape();
	shape.setAsBox((rw-4)/Vars.PPM, (rh)/Vars.PPM);
	
	bdef.position.set(x/Vars.PPM, y/Vars.PPM);
	bdef.type = BodyType.KinematicBody;
	fdef.shape = shape;
	
	body = world.createBody(bdef);
	body.setUserData(this);
	fdef.filter.maskBits = (short) (layer | Vars.BIT_GROUND | Vars.BIT_BATTLE);
	fdef.filter.categoryBits = layer;
	fdef.isSensor = true;
	body.setBullet(true);
	body.createFixture(fdef).setUserData(Vars.trimNumbers(ID));
	body.setFixedRotation(true);
}
 
开发者ID:JayKEm,项目名称:Aftamath,代码行数:23,代码来源:CamBot.java

示例9: create

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public void create() {
	init = true;
	PolygonShape shape = new PolygonShape();
	shape.setAsBox((rw)/Vars.PPM, (rh)/Vars.PPM);

	bdef.position.set(x/Vars.PPM, y/Vars.PPM);
	bdef.type = BodyType.KinematicBody;
	fdef.shape = shape;
	
	fdef.isSensor = true;
	body = world.createBody(bdef);
	body.setUserData(this);
	fdef.filter.maskBits = (short) ( Vars.BIT_GROUND | Vars.BIT_BATTLE| Vars.BIT_LAYER1| Vars.BIT_PLAYER_LAYER| Vars.BIT_LAYER3);
	fdef.filter.categoryBits = (short) ( Vars.BIT_GROUND | Vars.BIT_BATTLE| Vars.BIT_LAYER1| Vars.BIT_PLAYER_LAYER| Vars.BIT_LAYER3);
	body.createFixture(fdef).setUserData(Vars.trimNumbers(ID));
}
 
开发者ID:JayKEm,项目名称:Aftamath,代码行数:17,代码来源:TextTrigger.java

示例10: create

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public void create() {
	PolygonShape shape = new PolygonShape();
	shape.setAsBox((width/2-2)/Vars.PPM, (height/2)/Vars.PPM);

	bdef.position.set(x/Vars.PPM, y/Vars.PPM);
	bdef.type = BodyType.KinematicBody;
	fdef.shape = shape;
	
	fdef.isSensor = true;
	if(world==null) world = main.getWorld();
	body = world.createBody(bdef);
	body.setUserData(this);
	fdef.filter.maskBits = (short) ( Vars.BIT_GROUND | Vars.BIT_BATTLE| Vars.BIT_LAYER1| Vars.BIT_PLAYER_LAYER| Vars.BIT_LAYER3);
	fdef.filter.categoryBits = (short) ( Vars.BIT_GROUND | Vars.BIT_BATTLE| Vars.BIT_LAYER1| Vars.BIT_PLAYER_LAYER| Vars.BIT_LAYER3);
	body.createFixture(fdef).setUserData(Vars.trimNumbers("eventTrigger"));
}
 
开发者ID:JayKEm,项目名称:Aftamath,代码行数:17,代码来源:EventTrigger.java

示例11: SecurityCam

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public SecurityCam(World world, float x, float y, float width, float height) {
	WIDTH = width;
	HEIGHT = height;
	position.x = x;
	position.y = y;
	movAng=true;

	BodyDef bodyDef = new BodyDef();
	bodyDef.type = BodyType.KinematicBody;
	bodyDef.position.set(x, y);
	bodyDef.fixedRotation = true;

	PolygonShape shape = new PolygonShape();
	shape.setAsBox(width / 2, HEIGHT / 2, new Vector2(0,-height/2), 0);

	FixtureDef fixtureDef = new FixtureDef();
	fixtureDef.shape = shape;
	fixtureDef.restitution = 0;
	fixtureDef.friction = 0;
	fixtureDef.density = 3;

	body = world.createBody(bodyDef);
	fixture = body.createFixture(fixtureDef);
	
	shape.dispose();
}
 
开发者ID:CODA-Masters,项目名称:Little-Nibolas,代码行数:27,代码来源:SecurityCam.java

示例12: renderBody

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
protected void renderBody (Body body) {
	Transform transform = body.getTransform();
	int len = body.getFixtureList().size;
	Array<Fixture> fixtures = body.getFixtureList();
	for (int i = 0; i < len; i++) {
		Fixture fixture = fixtures.get(i);

		if (drawBodies) {
			if (body.isActive() == false && drawInactiveBodies)
				drawShape(fixture, transform, SHAPE_NOT_ACTIVE);
			else if (body.getType() == BodyType.StaticBody)
				drawShape(fixture, transform, SHAPE_STATIC);
			else if (body.getType() == BodyType.KinematicBody)
				drawShape(fixture, transform, SHAPE_KINEMATIC);
			else if (body.isAwake() == false)
				drawShape(fixture, transform, SHAPE_NOT_AWAKE);
			else
				drawShape(fixture, transform, SHAPE_AWAKE);
		}

		if (drawAABBs) {
			drawAABB(fixture, transform);
		}
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:Box2DDebugRenderer.java

示例13: createBody

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
/** Create a rigid body given a definition. No reference to the definition is retained.
 * @warning This function is locked during callbacks. */
public Body createBody (BodyDef def) {
	org.jbox2d.dynamics.BodyDef bd = new org.jbox2d.dynamics.BodyDef();
	bd.active = def.active;
	bd.allowSleep = def.allowSleep;
	bd.angle = def.angle;
	bd.angularDamping = def.angularDamping;
	bd.angularVelocity = def.angularVelocity;
	bd.awake = def.awake;
	bd.bullet = def.bullet;
	bd.fixedRotation = def.fixedRotation;
	bd.gravityScale = def.gravityScale;
	bd.linearDamping = def.linearDamping;
	bd.linearVelocity.set(def.linearVelocity.x, def.linearVelocity.y);
	bd.position.set(def.position.x, def.position.y);
	if (def.type == BodyType.DynamicBody) bd.type = org.jbox2d.dynamics.BodyType.DYNAMIC;
	if (def.type == BodyType.StaticBody) bd.type = org.jbox2d.dynamics.BodyType.STATIC;
	if (def.type == BodyType.KinematicBody) bd.type = org.jbox2d.dynamics.BodyType.KINEMATIC;

	org.jbox2d.dynamics.Body b = world.createBody(bd);
	Body body = new Body(this, b);
	bodies.put(b, body);
	return body;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:World.java

示例14: render

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
@Override
public void render () {
	if (m_platform.getType() == BodyType.KinematicBody) {
		Vector2 p = m_platform.getTransform().getPosition();
		Vector2 v = m_platform.getLinearVelocity();

		if ((p.x < -10 && v.x < 0) || (p.x > 10 && v.x > 0)) {
			v.x = -v.x;
			m_platform.setLinearVelocity(v);
		}
	}

	super.render();

	// if (renderer.batch != null) {
	// renderer.batch.begin();
	// // renderer.batch.drawText(renderer.font, "Keys: (d) dynamic, (s) static, (k) kinematic", 0, Gdx.app.getGraphics()
	// // .getHeight(), Color.WHITE);
	// renderer.batch.end();
	// }
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:22,代码来源:BodyTypes.java

示例15: KnightEntity

import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; //导入方法依赖的package包/类
public KnightEntity(String name, Position position, final GameWorld world) {
	super(name, position, world.GetAssetsHandler(), world.GetBodyDAL(), world.GetBox2DWorld());
	_world = world;

	// Animated model component
	AnimatedModelComponent modelCompo = new AnimatedModelComponent(_MODEL_COMPONENT_NAME, this, (Model)_assetsHndlr.get(_KNIGHT_MODEL_NAME), new ColorAttribute(ColorAttribute.AmbientLight, 1f, 1f, 1f, 1.0f));
	_controller = modelCompo.GetAnimationController();
	modelCompo.SetScale(_SCALE);
	addComponent(modelCompo);
	_controller.setAnimation(_KNIGHT_BREATHEFORE_ANIMATION, -1, 1f, null);
	_controller.animate(_KNIGHT_START_ANIMATION, 0f);
	
	// Player control component
	_playerCompo = new PlayerComponent(_PLAYER_COMPONENT_NAME, this);
	_world.GetInputMultiplexer().addProcessor(_playerCompo);
	_playerMoveListener = new PlayerMoveListener();
	_playerCompo.AddMoveListener(_playerMoveListener);
	addComponent(_playerCompo);
	
	// Knight box2D body
	BodyDef bodyDef = new BodyDef();
	bodyDef.position.set(position.x, position.y);
	bodyDef.type = BodyType.KinematicBody;
	FixtureDef fixtureDef = new FixtureDef();
	fixtureDef.density = 1;
	fixtureDef.friction = 0.5f;
	fixtureDef.restitution = 0.3f;
	_bodyCompo = new BodyComponent("knight_body", this, _box2DWorld, _bodyDAL, bodyDef, fixtureDef);
	_bodyCompo.setUserData(this);
	addComponent(_bodyCompo);
}
 
开发者ID:mitsuhirato,项目名称:TheEndlessCastle,代码行数:32,代码来源:KnightEntity.java


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