本文整理了Java中org.jbox2d.dynamics.Body.setActive()
方法的一些代码示例,展示了Body.setActive()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body.setActive()
方法的具体详情如下:
包路径:org.jbox2d.dynamics.Body
类名称:Body
方法名:setActive
[英]Set the active state of the body. An inactive body is not simulated and cannot be collided with or woken up. If you pass a flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false, all fixtures will be removed from the broad-phase and all contacts will be destroyed. Fixtures and joints are otherwise unaffected. You may continue to create/destroy fixtures and joints on inactive bodies. Fixtures on an inactive body are implicitly inactive and will not participate in collisions, ray-casts, or queries. Joints connected to an inactive body are implicitly inactive. An inactive body is still owned by a World object and remains in the body list.
[中]设置主体的活动状态。非活动物体不被模拟,不能碰撞或唤醒。如果您传递了true标志,则所有装置都将添加到宽阶段。如果您通过false标志,则所有固定装置将从宽相位中移除,所有触点将被销毁。固定装置和接头不受影响。可以继续在非活动实体上创建/销毁装置和关节。非活动实体上的装置隐式处于非活动状态,不会参与碰撞、光线投射或查询。连接到非活动实体的关节隐式处于非活动状态。非活动实体仍由世界对象拥有,并保留在实体列表中。
代码示例来源:origin: libgdx/libgdx
/** Set the active state of the body. An inactive body is not simulated and cannot be collided with or woken up. If you pass a
* flag of true, all fixtures will be added to the broad-phase. If you pass a flag of false, all fixtures will be removed from
* the broad-phase and all contacts will be destroyed. Fixtures and joints are otherwise unaffected. You may continue to
* create/destroy fixtures and joints on inactive bodies. Fixtures on an inactive body are implicitly inactive and will not
* participate in collisions, ray-casts, or queries. Joints connected to an inactive body are implicitly inactive. An inactive
* body is still owned by a b2World object and remains in the body list. */
public void setActive (boolean flag) {
body.setActive(flag);
}
代码示例来源:origin: jbox2d/jbox2d
@Override
public void keyPressed(char key, int argKeyCode) {
switch (key) {
case '1':
case '2':
case '3':
case '4':
case '5':
Create(key - '1');
break;
case 'a':
for (int i = 0; i < k_maxBodies; i += 2) {
if (m_bodies[i] != null) {
boolean active = m_bodies[i].isActive();
m_bodies[i].setActive(!active);
}
}
break;
case 'd':
DestroyBody();
break;
}
}
代码示例来源:origin: mirkosertic/GameComposer
void enableDynamicPhysicsOn(GameObjectInstance aInstance) {
Body theSimulatedBody = dynamicObjects.get(aInstance);
if (theSimulatedBody != null) {
theSimulatedBody.setActive(true);
}
}
代码示例来源:origin: mirkosertic/GameComposer
void disableDynamicPhysicsOn(GameObjectInstance aInstance) {
Body theSimulatedBody = dynamicObjects.get(aInstance);
if (theSimulatedBody != null) {
theSimulatedBody.setActive(false);
}
}
代码示例来源:origin: mirkosertic/GameComposer
@Override
public void handleGameEvent(PropertyChanged aEvent) {
GameObjectInstance theInstance = (GameObjectInstance) aEvent.getOwner();
Body theBody = staticObjects.get(theInstance);
if (theBody == null) {
theBody = dynamicObjects.get(theInstance);
}
if (theBody != null) {
if (!theInstance.visibleProperty().isNull()) {
theBody.setActive(theInstance.visibleProperty().get());
}
}
}
}
代码示例来源:origin: mirkosertic/GameComposer
@Override
public void handleGameEvent(PropertyChanged aEvent) {
if (!insimulation) {
GameObject theChangedObject = (GameObject) aEvent.getOwner();
Set<GameObjectInstance> theChangedInstances = new HashSet<>();
for (GameObjectInstance theObjectInstance : dynamicObjects.keySet()) {
if (theObjectInstance.getOwnerGameObject() == theChangedObject) {
theChangedInstances.add(theObjectInstance);
}
}
for (GameObjectInstance theObjectInstance : staticObjects.keySet()) {
if (theObjectInstance.getOwnerGameObject() == theChangedObject) {
theChangedInstances.add(theObjectInstance);
}
}
for (GameObjectInstance theInstance : theChangedInstances) {
Body theOldBody = gameObjectInstanceRemovedFromScene(theInstance);
Body theNewBody = gameObjectInstanceAddedToScene(theInstance);
if (theOldBody != null && theNewBody != null) {
theNewBody.setActive(theOldBody.isActive());
}
}
}
}
}
代码示例来源:origin: org.jbox2d/jbox2d-testbed
@Override
public void keyPressed(char key, int argKeyCode) {
switch (key) {
case '1':
case '2':
case '3':
case '4':
case '5':
Create(key - '1');
break;
case 'a':
for (int i = 0; i < k_maxBodies; i += 2) {
if (m_bodies[i] != null) {
boolean active = m_bodies[i].isActive();
m_bodies[i].setActive(!active);
}
}
break;
case 'd':
DestroyBody();
break;
}
}
内容来源于网络,如有侵权,请联系作者删除!