當前位置: 首頁>>代碼示例>>Java>>正文


Java BodyDef.BodyType方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.physics.box2d.BodyDef.BodyType方法的典型用法代碼示例。如果您正苦於以下問題:Java BodyDef.BodyType方法的具體用法?Java BodyDef.BodyType怎麽用?Java BodyDef.BodyType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.physics.box2d.BodyDef的用法示例。


在下文中一共展示了BodyDef.BodyType方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createEntityBody

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
/**
 * Erlaubt es den Unterklassen möglichst einfach einen beliebigen Box2D Körper zu erstellen.
 *
 * @param position die Startposition des Body
 * @param shape die Form, die für dne Body verwendet werden soll
 * @param type der Typ des Körpers
 * @return ein Box2D Körper
 */
protected Body createEntityBody(Vector2 position, Shape shape, BodyDef.BodyType type)
{
    position.scl(Physics.MPP);

    BodyDef bodyDef = new BodyDef();
    bodyDef.type = type;
    bodyDef.position.set(position);
    bodyDef.fixedRotation = true;

    Body body = worldObjectManager.getPhysicalWorld().createBody(bodyDef);
    body.setUserData(this);

    FixtureDef fixture = new FixtureDef();
    fixture.shape = shape;
    fixture.filter.categoryBits = Physics.CATEGORY_ENTITIES;
    fixture.filter.maskBits = Physics.MASK_ENTITIES;

    body.createFixture(fixture).setUserData(this);

    shape.dispose();

    return body;
}
 
開發者ID:Entwicklerpages,項目名稱:school-game,代碼行數:32,代碼來源:BaseEntity.java

示例2: createGameObjectWithBox2DBody

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
public static GameObject createGameObjectWithBox2DBody(Vector2 gameObjectPos, Texture texture, Vector3 densityFrictionRestitution,
                                   BodyDef.BodyType bodyType, Shape.Type shapeType,
                                   World world) {
    GameObject gameObject = new GameObject();
    gameObject.setPosition(gameObjectPos.x, gameObjectPos.y);
    gameObject.setTexture(texture);
    gameObject.setSprite(new Sprite(texture));
    gameObject.getSprite().setOriginCenter();
    gameObject.setWorld(world);
    BodyCreator bodyCreator = new BodyCreator();
    gameObject.setBody(bodyCreator.createBody(new Vector2(gameObject.getX(), gameObject.getY()), texture, bodyType, world, shapeType, densityFrictionRestitution));
    bodyCreator = null;
    return gameObject;
}
 
開發者ID:hypeofpipe,項目名稱:Race99,代碼行數:15,代碼來源:GameObjectFactory.java

示例3: createBody

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
public Body createBody(Vector2 position, Texture texture, BodyDef.BodyType bodyType, World world, Shape.Type shape, Vector3 densityRestitutionFriction) {
    this.texture = texture;
    bodyDef = createBodyDef(bodyType, position);
    body = world.createBody(bodyDef);
    FixtureCreator.createFixture(body, createShape(shape), densityRestitutionFriction);
    return body;
}
 
開發者ID:hypeofpipe,項目名稱:Race99,代碼行數:8,代碼來源:BodyCreator.java

示例4: boxBody

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
public static Body boxBody(World world,BodyDef.BodyType type, Vector2 position, Vector2 dimensions, float thickness,float density, float friction, float restitution,boolean isSensor){
	Body b = world.createBody(bodyDef(type,position));
	PolygonShape s = new PolygonShape();
	            
	FixtureDef fd = fixtureDef(density,friction,restitution,s,isSensor);
	//top
	s.setAsBox(dimensions.x, thickness, new Vector2(position.x,position.y + dimensions.y), 0);
	fd.shape = s;
	b.createFixture(fd);
	
	//Bottom
	s.setAsBox(dimensions.x, thickness, new Vector2(position.x,position.y - dimensions.y), 0);
	fd.shape = s;
	b.createFixture(fd);
	
	//Left
	s.setAsBox(thickness, dimensions.y, new Vector2(position.x - dimensions.x,position.y), 0);
	fd.shape = s;
	b.createFixture(fd);
	
	//Right
	s.setAsBox(thickness, dimensions.y, new Vector2(position.x + dimensions.x,position.y), 0);
	fd.shape = s;
	b.createFixture(fd);
	
	s.dispose();
	
	return b;
}
 
開發者ID:Deftwun,項目名稱:ZombieCopter,代碼行數:30,代碼來源:Box2dHelper.java

示例5: createBodyDef

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
private BodyDef createBodyDef(BodyDef.BodyType bodyType, Vector2 position) {
    BodyDef bodyDef_ = new BodyDef();
    bodyDef_.type = bodyType;
    bodyDef_.position.set(position);
    return bodyDef_;
}
 
開發者ID:hypeofpipe,項目名稱:Race99,代碼行數:7,代碼來源:BodyCreator.java

示例6: getBodyType

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
public BodyDef.BodyType getBodyType() {
    return bodyDef.type;
}
 
開發者ID:alexschimpf,項目名稱:joe,代碼行數:4,代碼來源:EntityDefinition.java

示例7: getBodyType

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
@Override
protected BodyDef.BodyType getBodyType() {
    return BodyDef.BodyType.DynamicBody;
}
 
開發者ID:PLNech,項目名稱:BactMan-Adventures,代碼行數:5,代碼來源:Item.java

示例8: getBodyType

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
protected BodyDef.BodyType getBodyType() {
    return BodyDef.BodyType.StaticBody;
}
 
開發者ID:PLNech,項目名稱:BactMan-Adventures,代碼行數:4,代碼來源:PhysicalWorldObject.java

示例9: getBodyType

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
@Override
protected BodyDef.BodyType getBodyType() {
    return BodyDef.BodyType.KinematicBody;
}
 
開發者ID:PLNech,項目名稱:BactMan-Adventures,代碼行數:5,代碼來源:Player.java

示例10: bodyDef

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
public static BodyDef bodyDef(BodyDef.BodyType type, Vector2 position){
	BodyDef bd = new BodyDef();
	bd.type = type;
	bd.position.set(position);
	return bd;
}
 
開發者ID:Deftwun,項目名稱:ZombieCopter,代碼行數:7,代碼來源:Box2dHelper.java

示例11: circleBody

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
public static Body circleBody(World world, BodyDef.BodyType type, Vector2 position, float radius, float density,float friction,float restitution,boolean isSensor){
	Body b = world.createBody(bodyDef(type,position));
	circleFixture(b,radius,density,friction,restitution,isSensor);
	return b;
}
 
開發者ID:Deftwun,項目名稱:ZombieCopter,代碼行數:6,代碼來源:Box2dHelper.java

示例12: rectangleBody

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
public static Body rectangleBody(World world,BodyDef.BodyType type, Vector2 position, Vector2 dimensions, float density,float friction, float restitution,boolean isSensor){
	Body b = world.createBody(bodyDef(type,position));
	rectangleFixture(b,dimensions,density,friction,restitution,isSensor);
	return b;
}
 
開發者ID:Deftwun,項目名稱:ZombieCopter,代碼行數:6,代碼來源:Box2dHelper.java

示例13: triangleBody

import com.badlogic.gdx.physics.box2d.BodyDef; //導入方法依賴的package包/類
public static Body triangleBody(World world,BodyDef.BodyType type, Vector2 position, Vector2 dimensions, float density,float friction, float restitution,boolean isSensor){
	Body b = world.createBody(bodyDef(type,position));
	triangleFixture(b,dimensions,density,friction,restitution,isSensor);
	return b;
}
 
開發者ID:Deftwun,項目名稱:ZombieCopter,代碼行數:6,代碼來源:Box2dHelper.java


注:本文中的com.badlogic.gdx.physics.box2d.BodyDef.BodyType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。