0

Android で D-PAD キーボードを設計したいです。Android でユーザー設定が表示されます。使い方がわかりません。いくつかのコードを与える

4

1 に答える 1

5

ホイールを最初から発明しないでください。juseuseandengine:

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;
        }
于 2012-05-15T13:15:47.687 に答える