本文整理汇总了Java中com.jme3.bullet.collision.PhysicsCollisionEvent.getObjectA方法的典型用法代码示例。如果您正苦于以下问题:Java PhysicsCollisionEvent.getObjectA方法的具体用法?Java PhysicsCollisionEvent.getObjectA怎么用?Java PhysicsCollisionEvent.getObjectA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.bullet.collision.PhysicsCollisionEvent
的用法示例。
在下文中一共展示了PhysicsCollisionEvent.getObjectA方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
public void collision(PhysicsCollisionEvent event) {
if (space == null) {
return;
}
if (event.getObjectA() == this || event.getObjectB() == this) {
space.add(ghostObject);
ghostObject.setPhysicsLocation(getPhysicsLocation(vector));
space.addTickListener(this);
if (effect != null && spatial.getParent() != null) {
curTime = 0;
effect.setLocalTranslation(spatial.getLocalTranslation());
spatial.getParent().attachChild(effect);
effect.emitAllParticles();
}
space.remove(this);
spatial.removeFromParent();
}
}
示例2: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
if (hasCollided) {
return;
}
if ((event.getObjectA() != ghost && event.getObjectB() != ghost)
|| (event.getObjectA().getUserObject()
== event.getObjectB().getUserObject())) {
return;
}
PhysicsCollisionObject otherObject =
event.getObjectA().getUserObject() == spatial
? event.getObjectB()
: event.getObjectA();
int otherCollisionGroup = otherObject.getCollisionGroup();
if (otherCollisionGroup != CollisionGroups.CHARACTERS
&& otherCollisionGroup != CollisionGroups.WALLS
&& otherCollisionGroup != CollisionGroups.SPIRIT_STONE) {
return;
}
// This filters away shields
if (otherCollisionGroup == CollisionGroups.CHARACTERS) {
Spatial targetSpatial = (Spatial) otherObject.getUserObject();
if (targetSpatial.getControl(CCharacterPhysics.class) == null) {
return;
}
}
hasCollided = true;
if (otherObject.getCollisionGroup() == CollisionGroups.CHARACTERS) {
collidedWith = (Spatial) otherObject.getUserObject();
}
}
示例3: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
if ((event.getObjectA() != ghost && event.getObjectB() != ghost)
|| (event.getObjectA().getUserObject()
== event.getObjectB().getUserObject())) {
return;
}
PhysicsCollisionObject otherObject
= event.getObjectA().getUserObject() == spatial
? event.getObjectB()
: event.getObjectA();
int otherCollisionGroup = otherObject.getCollisionGroup();
if (otherCollisionGroup != CollisionGroups.CHARACTERS
&& otherCollisionGroup != CollisionGroups.WALLS
&& otherCollisionGroup != CollisionGroups.SPIRIT_STONE) {
return;
}
// This filters away shields
if (otherCollisionGroup == CollisionGroups.CHARACTERS) {
Spatial targetSpatial = (Spatial) otherObject.getUserObject();
if (targetSpatial.getControl(CCharacterPhysics.class) == null) {
return;
}
}
if (otherObject.getCollisionGroup() == CollisionGroups.CHARACTERS) {
Spatial otherSpatial = (Spatial) otherObject.getUserObject();
if (!spatial.getUserData(UserData.TEAM_ID).equals(otherSpatial.getUserData(UserData.TEAM_ID))) {
enemy = otherSpatial;
}
}
}
示例4: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
if (hasCollided) {
return;
}
if ((event.getObjectA() != ghost && event.getObjectB() != ghost)
|| (event.getObjectA().getUserObject()
== event.getObjectB().getUserObject())) {
return;
}
PhysicsCollisionObject otherObject = event.getObjectA().getUserObject()
== spatial ? event.getObjectB() : event.getObjectA();
int otherCollisionGroup = otherObject.getCollisionGroup();
if (otherCollisionGroup != CollisionGroups.CHARACTERS
&& otherCollisionGroup != CollisionGroups.WALLS
&& otherCollisionGroup != CollisionGroups.SPIRIT_STONE) {
return;
}
if (otherObject.getUserObject() == ignored) {
return;
}
// This filters away shields
if (otherCollisionGroup == CollisionGroups.CHARACTERS) {
Spatial targetSpatial = (Spatial) otherObject.getUserObject();
if (targetSpatial.getControl(CCharacterPhysics.class) == null) {
return;
}
}
hasCollided = true;
if (otherObject.getCollisionGroup() == CollisionGroups.CHARACTERS) {
collidedWith = (Spatial) otherObject.getUserObject();
}
}
示例5: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
boolean isA = myStone == event.getNodeA();
boolean isB = myStone == event.getNodeB();
if (!isA && !isB) {
return;
}
Spatial other = isA ? event.getNodeB() : event.getNodeA();
if (other == null) {
return;
}
int myCollisionGroup = isA ? event.getObjectA().getCollisionGroup()
: event.getObjectB().getCollisionGroup();
if (myCollisionGroup == CollisionGroups.NONE) {
return;
}
PhysicsCollisionObject otherPhysics = isA ? event.getObjectB()
: event.getObjectA();
int otherCollisionGroup = otherPhysics.getCollisionGroup();
CSpiritStonePhysics stonePhysics =
myStone.getControl(CSpiritStonePhysics.class);
int stoneId = myStone.getUserData(UserData.ENTITY_ID);
Integer otherTeamId = other.getUserData(UserData.TEAM_ID);
if (otherTeamId == null) {
if (stonePhysics.isPunched()) {
world.removeEntity(stoneId, RemovalReasons.COLLISION);
} else {
}
return;
}
int myTeamId = myStone.getUserData(UserData.TEAM_ID);
CInfluenceInterface influenceInterface =
other.getControl(CInfluenceInterface.class);
if (influenceInterface != null && stonePhysics.isPunched()
&& !otherTeamId.equals(myTeamId)) {
CActionQueue cQueue = other.getControl(CActionQueue.class);
EntityAction currentAction = cQueue.getCurrent();
int ownerId = myStone.getUserData(UserData.PLAYER_ID);
int playerEntityId = PlayerData
.getIntData(ownerId, PlayerData.ENTITY_ID);
Spatial playerEntity = world.getEntity(playerEntityId);
if (currentAction != null && currentAction instanceof ATrance) {
((ATrance) currentAction).activate(playerEntity);
world.removeEntity(stoneId, RemovalReasons.COLLISION);
return;
}
CInfluenceInterface playerInterface =
playerEntity.getControl(CInfluenceInterface.class);
CharacterInteraction.harm(playerInterface, influenceInterface,
M1_COMBINATION_DAMAGE, null, true);
world.removeEntity(stoneId, RemovalReasons.COLLISION);
} else if (stonePhysics.isPunched()
&& otherCollisionGroup == CollisionGroups.WALLS) {
world.removeEntity(stoneId, RemovalReasons.COLLISION);
}
}
示例6: collision
import com.jme3.bullet.collision.PhysicsCollisionEvent; //导入方法依赖的package包/类
@Override
public void collision(PhysicsCollisionEvent event) {
// TODO: This was copied from ACharge almost exactly. It might be time
// to write common method for this?
if (hasCollided) {
return;
}
if ((event.getObjectA() != ghost && event.getObjectB() != ghost)
|| (event.getObjectA().getUserObject()
== event.getObjectB().getUserObject())) {
return;
}
Spatial spatial = (Spatial) ghost.getUserObject();
PhysicsCollisionObject otherObject
= event.getObjectA().getUserObject() == spatial
? event.getObjectB()
: event.getObjectA();
int otherCollisionGroup = otherObject.getCollisionGroup();
// This filters away shields
if (otherCollisionGroup == CollisionGroups.CHARACTERS) {
Spatial targetSpatial = (Spatial) otherObject.getUserObject();
if (targetSpatial.getControl(CCharacterPhysics.class) == null) {
return;
}
}
Spatial collidedWith = (Spatial) otherObject.getUserObject();
EntityAction aCurrent
= collidedWith.getControl(CActionQueue.class).getCurrent();
if (aCurrent instanceof ATrance) {
((ATrance) aCurrent).activate(spatial);
ElectroCharge.end(spatial, ghost.getPhysicsSpace(), this, ghost);
return;
}
hasCollided = true;
Vector3f impulse = collidedWith.getLocalTranslation()
.subtract(spatial.getLocalTranslation()).setY(0f)
.normalizeLocal().multLocal(25000f);
collidedWith.getControl(CCharacterPhysics.class).applyImpulse(impulse);
CharacterInteraction.harm(spatial.getControl(CInfluenceInterface.class),
collidedWith.getControl(CInfluenceInterface.class),
100f, null, true);
ElectroCharge.end(spatial, ghost.getPhysicsSpace(), this, ghost);
}