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


Java Joint类代码示例

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


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

示例1: createPrismaticJoint

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
private Joint createPrismaticJoint(Body anchor, Body car, Vector2 start) 
{
	PrismaticJointDef pjd = new PrismaticJointDef();
	
	pjd.bodyA = anchor;
	pjd.bodyB = car;
	pjd.collideConnected = false;
	pjd.enableLimit = true;

	pjd.localAnchorA.set(start);
	pjd.localAnchorB.set(Vector2.Zero);
	
	pjd.localAxisA.set(-1,0);
	pjd.lowerTranslation = -150;
	pjd.upperTranslation = 150;
	
	pjd.maxMotorForce = 0;
	pjd.motorSpeed = 0;
	pjd.enableMotor = false;
	
	return world.createJoint(pjd);
}
 
开发者ID:ChainGangChase,项目名称:cgc-game,代码行数:23,代码来源:BodyFactory.java

示例2: jointToColor

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
/**
 * Translates b2d Joint to appropriate color, depending on state/type
 * Modify to suit your needs
 * @param joint
 * @return
 */

private static Color jointToColor(Joint joint) {
	switch (joint.getType()) {
	case RevoluteJoint:
	case PrismaticJoint:
	case DistanceJoint:
	case PulleyJoint:
	case MouseJoint:
	case GearJoint:
	case WeldJoint:
	case FrictionJoint:
		return Color.WHITE;

	case Unknown:
	default:
		return Color.WHITE;
	}
}
 
开发者ID:mediamonks,项目名称:tilt-game-android,代码行数:25,代码来源:DebugRenderer.java

示例3: createJoint

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
public Joint createJoint(JointModel jm){
	
	String name = uniqueJointName(jm.name);
	logger.debug("Creating Joint from model: " + name + " = " + jm.bodyA + "+" + jm.bodyB);
	Body bodyA = bodies.get(jm.bodyA),
		 bodyB = bodies.get(jm.bodyB);
	
	if (bodyA == null) logger.error("Can't create Joint. Body: " + jm.bodyA + " not found in scene.");
	if (bodyB == null) logger.error("Can't create Joint. Body: " + jm.bodyB + " nof found in scene.");
	
	Joint joint = jm.toJoint(world,bodyA,bodyB);
	joints.put(name,joint);
	logger.debug("Joint count = " + joints.size);
	if (listener != null) listener.jointAdded(joint);
	return joint;
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:17,代码来源:PhysicsScene.java

示例4: reset

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
public void reset() {
    if (world.isLocked()) {
        throw new GdxRuntimeException("PhysixSystem.reset called in locked state");
    }

    Array<Body> bodies = new Array();
    world.getBodies(bodies);
    for (Body body : bodies) {
        world.destroyBody(body);
    }

    Array<Joint> joints = new Array();
    world.getJoints(joints);
    for (Joint joint : joints) {
        world.destroyJoint(joint);
    }
}
 
开发者ID:GameDevWeek,项目名称:CodeBase,代码行数:18,代码来源:PhysixSystem.java

示例5: render

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
@Override
public void render() {
    super.render();
    //game.getPhysics().clearForces();

    for (WeldJointDef jointDef : flyingDartCollisionRule.jointDefs) {
        Log.debug(tag, "CreateJoint");
        physics.createJoint(jointDef);

    }
    flyingDartCollisionRule.jointDefs.clear();

    for (Joint joint : flyingDartCollisionRule.destroyJoints) {
        Log.debug(tag, "DestroyJoint");
        physics.destroyJoint(joint);

    }
    flyingDartCollisionRule.destroyJoints.clear();

}
 
开发者ID:Rubentxu,项目名称:GDX-Logic-Bricks,代码行数:21,代码来源:FlyingDartTest.java

示例6: read

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public RevoluteJointDef read(Json json, JsonValue jsonData, Class type)
{	
	RevoluteJointDef defaults = RubeDefaults.Joint.revoluteDef;
	
	RevoluteJointDef def = new RevoluteJointDef();
	
	Vector2 anchorA = json.readValue("anchorA", Vector2.class, defaults.localAnchorA, jsonData);
	Vector2 anchorB = json.readValue("anchorB", Vector2.class, defaults.localAnchorB, jsonData);
	
	if(anchorA != null && anchorB != null)
	{
		def.localAnchorA.set(anchorA);
		def.localAnchorB.set(anchorB);
		def.referenceAngle 	= json.readValue("refAngle", 		float.class, defaults.referenceAngle, jsonData);
		def.enableLimit 	= json.readValue("enableLimit", 	boolean.class, defaults.enableLimit, jsonData);
		def.lowerAngle 		= json.readValue("lowerLimit", 		float.class, defaults.lowerAngle, jsonData);
		def.upperAngle 		= json.readValue("upperLimit",  	float.class, defaults.upperAngle, jsonData);
		def.enableMotor 	= json.readValue("enableMotor", 	boolean.class, defaults.enableMotor, jsonData);
		def.motorSpeed 		= json.readValue("motorSpeed",  	float.class, defaults.motorSpeed, jsonData);
		def.maxMotorTorque 	= json.readValue("maxMotorTorque", 	float.class, defaults.maxMotorTorque, jsonData);
	}
	
	return def; 
}
 
开发者ID:tescott,项目名称:RubeLoader,代码行数:27,代码来源:JointSerializer.java

示例7: init

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
/**
 * Called by <code>B2FlxState</code> to setup the vertices.
 */
public static void init()
{	
	// Construct a world object.
	if(world == null)
		world = new World(_gravity, true);
	
	// Create the contact manager.		
	contact = new B2FlxContactManager(B2FlxB.world);
	
	if(FlxG.debug)
		B2FlxB.initDebugger();
	
	controllers = new Array<B2Controller>();
	scheduledForRemoval = new Array<FlxBasic>();
	scheduledForRevival = new Array<FlxBasic>();
	scheduledForInActive = new Array<B2FlxShape>();
	scheduledForActive = new Array<B2FlxShape>();
	scheduledForMove = new Array<B2FlxShape>();
	flxJoints = new Array<B2FlxJoint>();
	bodies = new Array<Body>();
	joints = new Array<Joint>();
}
 
开发者ID:flixel-gdx,项目名称:flixel-gdx-box2d,代码行数:26,代码来源:B2FlxB.java

示例8: createRopeJoint

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
public Joint createRopeJoint(Body b1, Body b2, float maxLength)
{
	RopeJointDef rjd = new RopeJointDef();
	rjd.bodyA = b1;
	rjd.bodyB = b2;
	rjd.collideConnected = true;
	rjd.localAnchorA.set(Vector2.Zero);
	rjd.localAnchorB.set(Vector2.Zero);
	rjd.maxLength = maxLength;
	return world.createJoint(rjd);
}
 
开发者ID:ChainGangChase,项目名称:cgc-game,代码行数:12,代码来源:BodyFactory.java

示例9: createWeldJoint

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
public Joint createWeldJoint(Body b1, Body b2, Vector2 anchor)
{
	WeldJointDef wjd = new WeldJointDef();
	
	wjd.bodyA = b1;
	wjd.bodyB = b2;
	wjd.collideConnected = false;
	wjd.localAnchorA.set(Vector2.Zero);
	wjd.localAnchorB.set(anchor);
	wjd.referenceAngle = 0.0f;
	
	return world.createJoint(wjd);
}
 
开发者ID:ChainGangChase,项目名称:cgc-game,代码行数:14,代码来源:BodyFactory.java

示例10: leftRightCenter

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
public void leftRightCenter(Player left, Player right, Joint center)
{
	left.setRightPlayer(right);
	left.setRightJoint(center);
	right.setLeftPlayer(left);
	right.setLeftJoint(center);
}
 
开发者ID:ChainGangChase,项目名称:cgc-game,代码行数:8,代码来源:Patcher.java

示例11: RenderOfJointPolyline

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
public RenderOfJointPolyline(Joint joint, VertexBufferObjectManager pVBO, float pMarkerSize) {
	super(joint);
	mMarkerSize = pMarkerSize;

	mXPoints = new float[4];
	mYPoints = new float[4];

	mEntity = new PolyLine(0, 0, mXPoints, mYPoints, pVBO);
	mEntity.setColor(1, 1, 1);	// just to overcome some polyline issues
}
 
开发者ID:mediamonks,项目名称:tilt-game-android,代码行数:11,代码来源:RenderOfJointPolyline.java

示例12: addJoint

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
public String addJoint(String name, Joint j){
	logger.debug("Joint added: " + name);
	
	joints.put(name,j);
	if (listener != null) listener.jointAdded(j);
	return name;
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:8,代码来源:PhysicsScene.java

示例13: destroy

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
public void destroy(){
	logger.debug(String.format("Destroying: %d fixtures, %d bodies, & %d joints...",
								fixtures.size,bodies.size,joints.size));
	
	for (Joint j : joints.values()){
		world.destroyJoint(j);
		if (listener != null) listener.jointRemoved(j);
		logger.debug("Joint Destroyed");
	}
	
	for (Body b : bodies.values()){
		for (Fixture f : b.getFixtureList()){
			b.destroyFixture(f);
			if (listener != null) listener.fixtureRemoved(f);
			logger.debug("Fixture Destroyed");
		}
		world.destroyBody(b);
		if (listener != null) listener.bodyRemoved(b);
		logger.debug("Body Destroyed");
	}


	fixtures.clear();
	bodies.clear();
	joints.clear();
	uniqueId = 0;
	primaryBody = null;
	logger.debug("---Destroyed");
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:30,代码来源:PhysicsScene.java

示例14: destroyJoint

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
public void destroyJoint(String name){
	logger.debug("Destroy Joint: " + name);
	Joint j = joints.get(name);	
	if (j != null){
		world.destroyJoint(j);
		joints.remove(name);
		if (listener != null) listener.jointRemoved(j);
	}
	else logger.debug("Could not destroy joint: " + name + " not found");
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:11,代码来源:PhysicsScene.java

示例15: toSceneModel

import com.badlogic.gdx.physics.box2d.Joint; //导入依赖的package包/类
public PhysicsSceneModel toSceneModel(){
	logger.debug("Creating Scene Model");
	PhysicsSceneModel physicsModel = new PhysicsSceneModel();		
	
	//Bodies
	for (ObjectMap.Entry<String,Body> bodyEntry : bodies.entries()){
		BodyModel bodyModel = new BodyModel(bodyEntry.key,bodyEntry.value);
		//clear un-named fixtures. We'll manually add them with names included
		bodyModel.fixtures.clear();
		
		//Fixtures
		for (ObjectMap.Entry<String,Fixture> fixtureEntry : fixtures.entries()){
			if (fixtureEntry.value.getBody() == bodyEntry.value){
				FixtureModel fixModel = new FixtureModel(fixtureEntry.key,fixtureEntry.value);
				bodyModel.fixtures.add(fixModel);
			}
		}
		physicsModel.bodyModels.add(bodyModel);
	}
	
	//Joints
	for (ObjectMap.Entry<String,Joint> jointEntry : joints.entries()){
		Joint j = jointEntry.value;
		JointModel jointModel = new JointModel(jointEntry.key,jointEntry.value,getName(j.getBodyA()), getName(j.getBodyB()));
		physicsModel.jointModels.add(jointModel);
	}
	return physicsModel;
}
 
开发者ID:Deftwun,项目名称:ZombieCopter,代码行数:29,代码来源:PhysicsScene.java


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