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() {

            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.setOffsetCenter(0, 0);
        controlBase.setScaleCenter(10, 10);

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!

  • \$\begingroup\$ Do you ever call refreshControlKnobPosition() in your update code? Is the knob logging onControlChange? \$\endgroup\$
    – House
    Feb 25, 2013 at 19:12
  • \$\begingroup\$ 1) If I put a Log.v(TAG, "msg") inside the onControlChange(), I get the verbose log at every screen update. This means that onControlChange() is being called. 2) To which update code are you referring? Thank you for your support. \$\endgroup\$
    – Shailen
    Feb 25, 2013 at 20:06
  • \$\begingroup\$ Your main loop, or update loop. I'm not sure if you're required to update the knob position or it's done automatically. \$\endgroup\$
    – House
    Feb 25, 2013 at 20:10
  • \$\begingroup\$ I proofread my code. The whole code snippet posted (and therefore the refreshControlKnobPosition() function) is run in the main loop (onLoadScene()). This bug is very strange. \$\endgroup\$
    – Shailen
    Feb 25, 2013 at 20:22
  • 1
    \$\begingroup\$ @shailenTJ It's actually pretty sensible as a child scene. The on screen controls relies on having its own relative coordinate system, so it knows how far you're pushing the knob from a fixed point, regardless of the outside scene coordinates. I think you should consider posting an answer to your question and accepting it. \$\endgroup\$ Feb 26, 2013 at 22:29

1 Answer 1


The DigitalOnScreenControl cannot be attached as a child to a scene. It must be attached as a childscene to the Engine's current Scene.


In the above code, joystickControl extends a DigitalOnScreenControl object. After that, depending on how your game is organised, you may need to sort the scenes, in case the DigitalOnScreenControl does not appear.


Also, read Cameron Fredman's comment why it is sensible to add the DigitalOnScreenControl object as a childscene.

  • \$\begingroup\$ Almost done. Now click the check mark next to your answer! :) \$\endgroup\$ Feb 28, 2013 at 9:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .