package mygame; import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; import com.jme3.scene.Node; import com.jme3.scene.Spatial; import com.jme3.scene.control.AbstractControl; import com.jme3.scene.control.Control; /** * * @author Snowsun */ public class HitStarControl extends AbstractControl { private boolean isHited = false; private Node starNode; public HitStarControl(Node starNode) { this.starNode = starNode; } @Override protected void controlUpdate(float tpf) { if (isHited) { //Do some stuff for example spawn particels System.out.println(spatial.getName() + " is hited"); starNode.detachChild(spatial); } } @Override protected void controlRender(RenderManager rm, ViewPort vp) { } public Control cloneForSpatial(Spatial spatial) { HitStarControl control = new HitStarControl(starNode); spatial.addControl(control); return control; } public void setIsHited(boolean isHited) { this.isHited = isHited; } public boolean getIsHited() { return isHited; } }