/** * If enabled, add this control's physics object to the specified physics * space. If not enabled, alter where the object would be added. The object * is removed from any other space it's in. * * @param newSpace where to add, or null to simply remove */ @Override public void setPhysicsSpace(PhysicsSpace newSpace) { if (space == newSpace) { return; } if (added) { removePhysics(space); added = false; } if (newSpace != null && isEnabled()) { addPhysics(newSpace); added = true; } /* * If this control isn't enabled, its physics object will be * added to the new space when the control becomes enabled. */ space = newSpace; }
/** * If enabled, add this control's physics object to the specified physics * space. If not enabled, alter where the object would be added. The object * is removed from any other space it's in. * * @param newSpace where to add, or null to simply remove */ @Override public void setPhysicsSpace(PhysicsSpace newSpace) { if (space == newSpace) { return; } if (added) { removePhysics(space); added = false; } if (newSpace != null && isEnabled()) { addPhysics(newSpace); added = true; } /* * If this control isn't enabled, its physics object will be * added to the new space when the control becomes enabled. */ space = newSpace; }
/** * Enable or disable this control. * <p> * When the control is disabled, the physics object is removed from physics * space. When the control is enabled again, the physics object is moved to * the spatial's location and then added to the physics space. * * @param enabled true→enable the control, false→disable it */ public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } addPhysics(space); added = true; } else if (!enabled && added) { removePhysics(space); added = false; } } }
/** * Enable or disable this control. * <p> * When the control is disabled, the physics object is removed from physics * space. When the control is enabled again, the physics object is moved to * the spatial's location and then added to the physics space. * * @param enabled true→enable the control, false→disable it */ public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } addPhysics(space); added = true; } else if (!enabled && added) { removePhysics(space); added = false; } } }
public void setPhysicsSpace(PhysicsSpace space) { if (space == null) { if (this.space != null) { removePhysics(this.space); added = false; } } else { if (this.space == space) { return; } else if (this.space != null) { removePhysics(this.space); } addPhysics(space); added = true; } this.space = space; }
/** * If enabled, add this control's physics object to the specified physics * space. If not enabled, alter where the object would be added. The object * is removed from any other space it's in. * * @param newSpace where to add, or null to simply remove */ @Override public void setPhysicsSpace(PhysicsSpace newSpace) { if (space == newSpace) { return; } if (added) { removePhysics(space); added = false; } if (newSpace != null && isEnabled()) { addPhysics(newSpace); added = true; } /* * If this control isn't enabled, its physics object will be * added to the new space when the control becomes enabled. */ space = newSpace; }
public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } addPhysics(space); added = true; } else if (!enabled && added) { removePhysics(space); added = false; } } }
/** * Enable or disable this control. * <p> * When the control is disabled, the physics object is removed from physics * space. When the control is enabled again, the physics object is moved to * the spatial's location and then added to the physics space. * * @param enabled true→enable the control, false→disable it */ public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } addPhysics(space); added = true; } else if (!enabled && added) { removePhysics(space); added = false; } } }