Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
Do you ever call refreshControlKnobPosition() in your update code? Is the knob logging onControlChange? – Byte56 Feb 25 '13 at 19:12
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. – shailenTJ Feb 25 '13 at 20:06
Your main loop, or update loop. I'm not sure if you're required to update the knob position or it's done automatically. – Byte56 Feb 25 '13 at 20:10
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. – shailenTJ Feb 25 '13 at 20:22
@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. – Cameron Fredman Feb 26 '13 at 22:29
up vote 1 down vote accepted

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.

share|improve this answer
Almost done. Now click the check mark next to your answer! :) – Cameron Fredman Feb 28 '13 at 9:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.