我的AndEngine应用不会显示选项菜单

时间:2015-07-16 01:27:22

标签: andengine

我使用AndEngine开发一个简单的测试应用程序。一切都很好,但菜单选项没有显示。我不知道为什么我没有看到选项菜单按钮(右下角的3点触摸按钮)。非常感谢帮助。

enter image description here 以下是与MenuScene

对应的代码段
    public class MainActivity extends SimpleBaseGameActivity implements IOnMenuItemClickListener {
        private static int CAMERA_WIDTH ;
        private static int CAMERA_HEIGHT;

        protected static final int MENU_ADD = 0;
        protected static final int MENU_QUIT = MENU_ADD + 1;



        private Font mFont,menuFont;
        private MenuScene mMenuScene;
        Camera camera;
        Scene scene;

        @Override
        public EngineOptions onCreateEngineOptions() {
//default code
        }

        @Override
        public void onCreateResources() throws IOException {
//some code
        }

        @Override
        public Scene onCreateScene() {
 //some code
        }

        @Override
        public boolean onMenuItemClicked(final MenuScene pMenuScene, final IMenuItem pMenuItem, final float pMenuItemLocalX, final float pMenuItemLocalY) {
            switch(pMenuItem.getID()) {
            case MENU_ADD:
                /* Restart the animation. */
                Log.i("hello", "Menu ADD CLICKED");
                return true;

            case MENU_QUIT:
                /* End Activity. */
                this.finish();
                return true;

            default:
                return false;
            }
        }

        protected MenuScene createMenuScene() {
            final MenuScene menuScene = new MenuScene(this.camera, new AlphaMenuSceneAnimator());

            final IMenuItem resetMenuItem = new ColorMenuItemDecorator(new TextMenuItem(MENU_ADD, this.menuFont, "ADD ITEM", this.getVertexBufferObjectManager()), new Color(1,0,0), new Color(0,0,0));
            menuScene.addMenuItem(resetMenuItem);
            final IMenuItem quitMenuItem = new ColorMenuItemDecorator(new TextMenuItem(MENU_QUIT, this.menuFont, "QUIT", this.getVertexBufferObjectManager()), new Color(1,0,0), new Color(0,0,0));

            menuScene.addMenuItem(quitMenuItem);
            menuScene.buildAnimations();
            menuScene.setBackgroundEnabled(false);
            menuScene.setOnMenuItemClickListener(this);
            return menuScene;
        }

        @Override
        public boolean onKeyDown(final int pKeyCode, final KeyEvent pEvent) {
            if(pKeyCode == KeyEvent.KEYCODE_MENU && pEvent.getAction() == KeyEvent.ACTION_DOWN) {
                if(this.scene.hasChildScene()) {
                    /* Remove the menu and reset it. */
                    this.mMenuScene.back();
                } else {
                    /* Attach the menu. */
                    this.scene.setChildScene(this.mMenuScene, false, true, true);
                }
                return true;
            } else {
                return super.onKeyDown(pKeyCode, pEvent);
            }
        }


    }

0 个答案:

没有答案