本文整理汇总了Java中org.jbox2d.dynamics.World.setContactListener方法的典型用法代码示例。如果您正苦于以下问题:Java World.setContactListener方法的具体用法?Java World.setContactListener怎么用?Java World.setContactListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jbox2d.dynamics.World
的用法示例。
在下文中一共展示了World.setContactListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Scene
import org.jbox2d.dynamics.World; //导入方法依赖的package包/类
public Scene() {
sun = new DirectionalLight(vec3(-1.0f, -1.0f, 0.2f), vec3(2.0f, 2.0f, 2.0f), Settings.ENABLE_SHADOWS, 30, Settings.SHADOW_RESOLUTION);
//setup bullet
BroadphaseInterface broadphase = new DbvtBroadphase();
DefaultCollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();
CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);
SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver();
world = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);
// set the gravity of our world
world.setGravity(new Vector3f(0, -9.8f, 0));
//setup jbox2D
world2D = new World(new Vector2(0, -9.8f));
world2D.setContactListener(this);
}
示例2: init
import org.jbox2d.dynamics.World; //导入方法依赖的package包/类
public void init(World world, boolean deserialized) {
m_world = world;
pointCount = 0;
stepCount = 0;
bombSpawning = false;
model.getDebugDraw().setViewportTransform(camera.getTransform());
world.setDestructionListener(destructionListener);
world.setParticleDestructionListener(particleDestructionListener);
world.setContactListener(this);
world.setDebugDraw(model.getDebugDraw());
title = getTestName();
initTest(deserialized);
}
示例3: init
import org.jbox2d.dynamics.World; //导入方法依赖的package包/类
public void init(World world, boolean deserialized) {
m_world = world;
pointCount = 0;
stepCount = 0;
bombSpawning = false;
model.getDebugDraw().setViewportTransform(camera.getTransform());
world.setDestructionListener(destructionListener);
world.setContactListener(this);
world.setDebugDraw(model.getDebugDraw());
title = getTestName();
initTest(deserialized);
}
示例4: init
import org.jbox2d.dynamics.World; //导入方法依赖的package包/类
public void init(DebugDraw argDebugDraw){
m_debugDraw = argDebugDraw;
destructionListener = new DestructionListener() {
public void sayGoodbye(Fixture fixture) {
}
public void sayGoodbye(Joint joint) {
if(m_mouseJoint == joint){
m_mouseJoint = null;
}else{
jointDestroyed(joint);
}
}
};
Vec2 gravity = new Vec2(0, -10f);
m_world = new World(gravity, true);
m_bomb = null;
m_textLine = 30;
m_mouseJoint = null;
m_pointCount = 0;
m_world.setDestructionListener(destructionListener);
m_world.setContactListener(this);
m_world.setDebugDraw(m_debugDraw);
bombSpawning = false;
m_stepCount = 0;
// Contact.activeContacts = 0;
BodyDef bodyDef = new BodyDef();
m_groundBody = m_world.createBody(bodyDef);
if(hasCachedCamera){
setCamera(cachedCameraX, cachedCameraY, cachedCameraScale);
}else{
setCamera(0, 10, 10);
}
setTitle(getTestName());
initTest();
}
示例5: PeaWorld
import org.jbox2d.dynamics.World; //导入方法依赖的package包/类
public PeaWorld(GroupLayer scaledLayer) {
staticLayerBack = graphics().createGroupLayer();
scaledLayer.add(staticLayerBack);
dynamicLayer = graphics().createGroupLayer();
scaledLayer.add(dynamicLayer);
staticLayerFront = graphics().createGroupLayer();
scaledLayer.add(staticLayerFront);
// create the physics world
Vec2 gravity = new Vec2(0.0f, 10.0f);
world = new World(gravity, true);
world.setWarmStarting(true);
world.setAutoClearForces(true);
world.setContactListener(this);
// create the ground
Body ground = world.createBody(new BodyDef());
PolygonShape groundShape = new PolygonShape();
groundShape.setAsEdge(new Vec2(0, height), new Vec2(width, height));
ground.createFixture(groundShape, 0.0f);
// create the walls
Body wallLeft = world.createBody(new BodyDef());
PolygonShape wallLeftShape = new PolygonShape();
wallLeftShape.setAsEdge(new Vec2(0, 0), new Vec2(0, height));
wallLeft.createFixture(wallLeftShape, 0.0f);
Body wallRight = world.createBody(new BodyDef());
PolygonShape wallRightShape = new PolygonShape();
wallRightShape.setAsEdge(new Vec2(width, 0), new Vec2(width, height));
wallRight.createFixture(wallRightShape, 0.0f);
if (showDebugDraw) {
CanvasLayer canvasLayer =
graphics().createCanvasLayer((int) (width / Peas.physUnitPerScreenUnit),
(int) (height / Peas.physUnitPerScreenUnit));
graphics().rootLayer().add(canvasLayer);
debugDraw = new DebugDrawBox2D();
debugDraw.setCanvas(canvasLayer);
debugDraw.setFlipY(false);
debugDraw.setStrokeAlpha(150);
debugDraw.setFillAlpha(75);
debugDraw.setStrokeWidth(2.0f);
debugDraw.setFlags(DebugDraw.e_shapeBit | DebugDraw.e_jointBit | DebugDraw.e_aabbBit);
debugDraw.setCamera(0, 0, 1f / Peas.physUnitPerScreenUnit);
world.setDebugDraw(debugDraw);
}
}