@Override public void onRemove() { super.onRemove(); aoscMovement.detachChild(aoscAction); getHUD().detachChild(aoscMovement); }
private void initControler() { if (aoscAction != null) { aoscMovement.detachChild(aoscAction); aoscAction.clearUpdateHandlers(); aoscAction.getControlKnob().clearUpdateHandlers(); } if (aoscAction != null) { getHUD().detachChild(aoscMovement); aoscMovement.clearUpdateHandlers(); aoscMovement.getControlKnob().clearUpdateHandlers(); } // ACTION this.iasAction = new IAnalogOnScreenControlListener() { private long lastTick; @Override public void onControlChange(BaseOnScreenControl pBosc, float pValueX, float pValueY) { long curr = System.currentTimeMillis(); AItemWeapon w = getMapPrinter().getPlayer().getPersonnageInfo().getWeapon(); if (lastTick <= curr) { lastTick = w.getProjectileRate() + curr; getMapPrinter().shotEntity(getMapPrinter().getPlayer(), pValueX, pValueY); } } @Override public void onControlClick(AnalogOnScreenControl pAnalogOnScreenControl) {} }; this.aoscAction = new AnalogOnScreenControl( 0, 0, getEngine().getVCamera(), getEngine() .getVRessourceManager() .getTexture(AuraTextureChooser.GUI_ANALOG_BG.getTexture()), getEngine() .getVRessourceManager() .getTexture(AuraTextureChooser.GUI_ANALOG_KNOB.getTexture()), .1f, iasAction); this.aoscAction.setPosition( getEngine().getVProperties().getCameraScreenWidth() - (aoscAction.getControlBase().getWidth() + 16), getEngine().getVProperties().getCameraScreenHeight() - (aoscAction.getControlBase().getHeight() + 16)); this.aoscAction.getControlKnob().setAlpha(.5f); this.aoscAction.getControlKnob().setZIndex(1000); this.aoscAction .getControlKnob() .setBlendFunction(GLES10.GL_SRC_ALPHA, GLES10.GL_ONE_MINUS_SRC_ALPHA); // MOVEMENT this.iasMovement = new IAnalogOnScreenControlListener() { @Override public void onControlChange(BaseOnScreenControl pBosc, float pValueX, float pValueY) { getMapPrinter().moveEntity(getMapPrinter().getPlayer(), pValueX, pValueY); } @Override public void onControlClick(AnalogOnScreenControl pAnalogOnScreenControl) {} }; this.aoscMovement = new AnalogOnScreenControl( 0, 0, getEngine().getVCamera(), getEngine() .getVRessourceManager() .getTexture(AuraTextureChooser.GUI_ANALOG_BG.getTexture()), getEngine() .getVRessourceManager() .getTexture(AuraTextureChooser.GUI_ANALOG_KNOB.getTexture()), .1f, iasMovement); this.aoscMovement.setPosition( 16, getEngine().getVProperties().getCameraScreenHeight() - (aoscMovement.getControlBase().getHeight() + 16)); this.aoscMovement.getControlKnob().setAlpha(.5f); this.aoscMovement.getControlKnob().setZIndex(1000); this.aoscMovement .getControlKnob() .setBlendFunction(GLES10.GL_SRC_ALPHA, GLES10.GL_ONE_MINUS_SRC_ALPHA); getHUD().setChildScene(aoscMovement); aoscMovement.setChildScene(aoscAction); aoscMovement.refreshControlKnobPosition(); aoscAction.refreshControlKnobPosition(); }