I have set up a DigitalOnScreenControl
in my game but the knob does not move. The base and the knob are drawn on the screen but the latter doesn't move as per the AndEngine example here.
Here is a snippet of my code:
this.mDigitalOnScreenControl = new DigitalOnScreenControl(300, 300, ResourceManager.getCamera(), ResourceManager.joystickControlBase,
ResourceManager.joystickControlKnob, 0.1f, ResourceManager.getActivity().getVertexBufferObjectManager(),
new IOnScreenControlListener() {
@Override
public void onControlChange(final BaseOnScreenControl pBaseOnScreenControl, final float pValueX,
final float pValueY) {
Log.v(TAG, "onControlChange");
}
});
final Sprite controlBase = this.mDigitalOnScreenControl.getControlBase();
final Sprite knob = this.mDigitalOnScreenControl.getControlKnob();
controlBase.setAlpha(0.5f);
controlBase.setOffsetCenter(0, 0);
controlBase.setScaleCenter(10, 10);
controlBase.setScale(1.25f);
knob.setScale(1.25f);
this.mDigitalOnScreenControl.refreshControlKnobPosition();
ResourceManager.getEngine().getScene().attachChild(this.mDigitalOnScreenControl);
The mDigitalOnScreenControl
is a DigitalOnScreenControl
object defined previously. I use a ResourceManager
class to obtain texture regions and other game resources such as the camera amongst others. Note: Since the base and the knob are drawn, the ITextureRegions
returned by the ResourceManager
are valid. When I execute the program, there are no errors in DDMS.
The knob just doesn't move. Does anybody have an idea?
Thank you!
refreshControlKnobPosition()
in your update code? Is the knob loggingonControlChange
? \$\endgroup\$Log.v(TAG, "msg")
inside theonControlChange()
, I get the verbose log at every screen update. This means thatonControlChange()
is being called. 2) To which update code are you referring? Thank you for your support. \$\endgroup\$refreshControlKnobPosition()
function) is run in the main loop (onLoadScene()
). This bug is very strange. \$\endgroup\$