當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。