2012-05-15 75 views
0

我想在android中設計D-PAD鍵盤。我在android中看到用戶配置。我不知道如何使用它。 給一些代碼如何在android中設計D-PAD keybord?

+0

有點,什麼樣的應用程序,你到目前爲止考慮,等等? –

+0

只是想設計一個D-PAD,其中每個鍵執行不同的操作。 –

+0

你將不得不更加具體地瞭解你需要什麼,到目前爲止你已經嘗試了什麼,以及你卡在哪裏。低質量的問題往往會被關閉。 –

回答

5

不要再發明從頭輪,JUSE使用andengine:

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

,你能否澄清加載必要的一切都在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; 
     }