示例#1
0
 /**
  * Returns the first control that is an instance of the given class, or null if no such control
  * exists.
  *
  * @param controlType The superclass of the control to look for.
  * @return The first instance in the list of the controlType class, or null.
  * @see Spatial#addControl(com.jme3.scene.control.Control)
  */
 public <T extends Control> T getControl(Class<T> controlType) {
   for (Control c : controls.getArray()) {
     if (controlType.isAssignableFrom(c.getClass())) {
       return (T) c;
     }
   }
   return null;
 }
示例#2
0
 /**
  * Removes the first control that is an instance of the given class.
  *
  * @see Spatial#addControl(com.jme3.scene.control.Control)
  */
 public void removeControl(Class<? extends Control> controlType) {
   for (int i = 0; i < controls.size(); i++) {
     if (controlType.isAssignableFrom(controls.get(i).getClass())) {
       Control control = controls.remove(i);
       control.setSpatial(null);
     }
   }
 }