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
Asked
Active
Viewed 5,587 times
-1
-
Could you clarify a bit, what sort of application, what you are considered so far, etc? – Chris Stratton May 15 '12 at 20:44
-
just want to design a D-PAD,where each key perform different operation. – Sanjoy Saha May 16 '12 at 04:04
-
You are going to have to be more specific about exactly what you need, what you have tried so far, and where you got stuck. Low quality questions tend to get closed. – Chris Stratton May 16 '12 at 04:16
-
what I want to do is to add 4 buttons on the screen (LIKE D-PAD) and these buttons should different operation With a clickListener and onClick() (or touchListener and onTouch()) – Sanjoy Saha May 16 '12 at 04:20
-
Have you seen the buttons examples in the api demos of the samples/ directory of the SDK? – Chris Stratton May 16 '12 at 04:24
-
want to design Virtual D-pad application.but i did not any example for that – Sanjoy Saha May 16 '12 at 04:52
-
Where in the process of evolving the simple button demos into your virtual D-pad did you get stuck? – Chris Stratton May 16 '12 at 04:56
-
Use this it may help http://stackoverflow.com/questions/14561251/dpad-is-disabled-in-emulator – GOLDEE Nov 13 '13 at 07:19
1 Answers
5
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;
}

Thkru
- 4,218
- 2
- 18
- 37