How to design D-PAD keybord in android?

5.6k views Asked by At

i want to design D-PAD keyboard in android .I see user configuration in android. i don't know how to use it. give some code

1

There are 1 answers

0
Thkru On

Don't invent the wheel from scratch again, juse use andengine:

http://www.andengine.org/blog/2010/07/andengine-on-screen-controls/

and load everything necessary in the onLoadScene()

@Override
        public Scene onLoadScene() {
                this.mEngine.registerUpdateHandler(new FPSLogger());

                final Scene scene = new Scene();
                scene.setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f));

                final int centerX = (CAMERA_WIDTH - this.mFaceTextureRegion.getWidth()) / 2;
                final int centerY = (CAMERA_HEIGHT - this.mFaceTextureRegion.getHeight()) / 2;
                final Sprite face = new Sprite(centerX, centerY, this.mFaceTextureRegion);
                final PhysicsHandler physicsHandler = new PhysicsHandler(face);
                face.registerUpdateHandler(physicsHandler);

                scene.attachChild(face);

                this.mDigitalOnScreenControl = new DigitalOnScreenControl(0, CAMERA_HEIGHT - this.mOnScreenControlBaseTextureRegion.getHeight(), this.mCamera, this.mOnScreenControlBaseTextureRegion, this.mOnScreenControlKnobTextureRegion, 0.1f, new IOnScreenControlListener() {
                        @Override
                        public void onControlChange(final BaseOnScreenControl pBaseOnScreenControl, final float pValueX, final float pValueY) {
                                physicsHandler.setVelocity(pValueX * 100, pValueY * 100);
                        }
                });
                this.mDigitalOnScreenControl.getControlBase().setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
                this.mDigitalOnScreenControl.getControlBase().setAlpha(0.5f);
                this.mDigitalOnScreenControl.getControlBase().setScaleCenter(0, 128);
                this.mDigitalOnScreenControl.getControlBase().setScale(1.25f);
                this.mDigitalOnScreenControl.getControlKnob().setScale(1.25f);
                this.mDigitalOnScreenControl.refreshControlKnobPosition();

                scene.setChildScene(this.mDigitalOnScreenControl);

                return scene;
        }