如何在安卓中设计D-PAD键盘

  • 本文关键字:D-PAD 键盘 android d-pad
  • 更新时间 :
  • 英文 :


我想在安卓中设计D-PAD键盘。我在安卓中看到用户配置。我不知道如何使用它。给出一些代码

不要再从头开始发明轮子了,juse use 和引擎:

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;
        }

相关内容

  • 没有找到相关文章

最新更新