コード例 #1
0
        public EmulatorButtons(EmulatorListener el, int w, int h, float scale)
        {
            this.emulatorListener = el;
            if (pack == null) {
                pack = new LTexturePack();
                pack.PutImage(XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "e1.png"));
                pack.PutImage(XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "e2.png"));
                pack.Pack(Loon.Core.Graphics.Opengl.LTexture.Format.LINEAR);
            }
            RectBox.Rect2i bounds = pack.GetEntry(0).getBounds();
            this.dpad = new LTextureRegion(pack.GetTexture(), bounds.left,
                    bounds.top, bounds.right, bounds.bottom);
            bounds = pack.GetEntry(1).getBounds();
            this.buttons = new LTextureRegion(pack.GetTexture(), bounds.left,
                    bounds.top, bounds.right, bounds.bottom);
            this.width = w;
            this.height = h;

            if (scale <= 0f) {
                this.up = new EmulatorButton(dpad, 40, 40, 40, 0, true, 60, 60);
                this.left = new EmulatorButton(dpad, 40, 40, 0, 40, true, 60, 60);
                this.right = new EmulatorButton(dpad, 40, 40, 80, 40, true, 60, 60);
                this.down = new EmulatorButton(dpad, 40, 40, 40, 80, true, 60, 60);

                this.triangle = new EmulatorButton(buttons, 48, 48, 48, 0, true,
                        68, 68);
                this.square = new EmulatorButton(buttons, 48, 48, 0, 48, true, 68,
                        68);
                this.circle = new EmulatorButton(buttons, 48, 48, 96, 48, true, 68,
                        68);
                this.cancel = new EmulatorButton(buttons, 48, 48, 48, 96, true, 68,
                        68);
            } else {

                this.up = new EmulatorButton(dpad, 40, 40, 40, 0, true,
                        (int) (60 * scale), (int) (60 * scale));
                this.left = new EmulatorButton(dpad, 40, 40, 0, 40, true,
                        (int) (60 * scale), (int) (60 * scale));
                this.right = new EmulatorButton(dpad, 40, 40, 80, 40, true,
                        (int) (60 * scale), (int) (60 * scale));
                this.down = new EmulatorButton(dpad, 40, 40, 40, 80, true,
                        (int) (60 * scale), (int) (60 * scale));

                this.triangle = new EmulatorButton(buttons, 48, 48, 48, 0, true,
                        (int) (68 * scale), (int) (68 * scale));
                this.square = new EmulatorButton(buttons, 48, 48, 0, 48, true,
                        (int) (68 * scale), (int) (68 * scale));
                this.circle = new EmulatorButton(buttons, 48, 48, 96, 48, true,
                        (int) (68 * scale), (int) (68 * scale));
                this.cancel = new EmulatorButton(buttons, 48, 48, 48, 96, true,
                        (int) (68 * scale), (int) (68 * scale));
            }

            if (dpad != null) {
                dpad.Dispose();
                dpad = null;
            }
            if (buttons != null) {
                buttons.Dispose();
                buttons = null;
            }
            this.visible = true;

            this.SetLocation(0, 0);
        }