示例#1
0
        public static bool Init()
        {
            graphics = new GraphicsContext();
            SampleDraw.Init(graphics);

            int sx = (graphics.Screen.Width / 2) - ((96 * 2) + (16 * 2));
            int sy = (graphics.Screen.Height / 2) - (96 / 2);

            playButton   = new SampleButton(sx + 0, sy - 24, 96, 48);
            stopButton   = new SampleButton(sx + 112, sy - 24, 96, 48);
            pauseButton  = new SampleButton(sx + 224, sy - 24, 96, 48);
            resumeButton = new SampleButton(sx + 336, sy - 24, 96, 48);
            volumeSlider = new SampleSlider(sx + 88, sy + 96, 256, 48);

            volTextPosX = (sx + 88) - 96;
            volTextPosY = (sy + 96) + 12;

            playButton.SetText("Play");
            stopButton.SetText("Stop");
            pauseButton.SetText("Pause");
            resumeButton.SetText("Resume");

            bgm       = new Bgm("/Application/Sample/Audio/BgmPlayerSample/GAME_BGM_01.mp3");
            bgmPlayer = bgm.CreatePlayer();

            return(true);
        }
示例#2
0
            public SoundButton(int id, int pixelX, int pixelY)
            {
                textSprite   = new SampleSprite("SE " + id, 0xffffffff, SampleDraw.CurrentFont, pixelX - 64, pixelY + 12);
                playButton   = new SampleButton(pixelX, pixelY, 96, 48);
                stopButton   = new SampleButton(pixelX + 112, pixelY, 96, 48);
                volumeSlider = new SampleSlider(pixelX + 224, pixelY, 256, 48);

                playButton.SetText("Play");
                stopButton.SetText("Stop");

                sound       = new Sound(soundName[id]);
                soundPlayer = sound.CreatePlayer();
            }
        // use objects intialize.
        private static void SetupObjects()
        {
            int sx   = (screenWidth - (BUTTON_NO * 128)) / 2;
            int soff = (128 - 96) / 2;

            button0 = new SampleButton(sx + (128 * 0) + soff, 128, 96, 48);
            button1 = new SampleButton(sx + (128 * 1) + soff, 128, 96, 48);
            button2 = new SampleButton(sx + (128 * 2) + soff, 128, 96, 48);
            button3 = new SampleButton(sx + (128 * 3) + soff, 128, 96, 48);

            if (0 == persistentMemoryData[STATE_ADDR_BUTTON0])
            {
                button0.SetText(BUTTON_RELEASE);
                button0.ButtonColor = DISABLE_COLOR;
            }
            else
            {
                button0.SetText(BUTTON_PRESS);
                button0.ButtonColor = ENABLE_COLOR;
            }

            if (0 == persistentMemoryData[STATE_ADDR_BUTTON1])
            {
                button1.SetText(BUTTON_RELEASE);
                button1.ButtonColor = DISABLE_COLOR;
            }
            else
            {
                button1.SetText(BUTTON_PRESS);
                button1.ButtonColor = ENABLE_COLOR;
            }

            if (0 == persistentMemoryData[STATE_ADDR_BUTTON2])
            {
                button2.SetText(BUTTON_RELEASE);
                button2.ButtonColor = DISABLE_COLOR;
            }
            else
            {
                button2.SetText(BUTTON_PRESS);
                button2.ButtonColor = ENABLE_COLOR;
            }

            if (0 == persistentMemoryData[STATE_ADDR_BUTTON3])
            {
                button3.SetText(BUTTON_RELEASE);
                button3.ButtonColor = DISABLE_COLOR;
            }
            else
            {
                button3.SetText(BUTTON_PRESS);
                button3.ButtonColor = ENABLE_COLOR;
            }

            // for slider setting
            byte[] byteArray = new byte[4];
            for (int i = 0; i < 4; i++)
            {
                byteArray[i] = persistentMemoryData[STATE_ADDR_SLIDER + i];
            }
            float rate = BitConverter.ToSingle(byteArray, 0);

            sx          = (screenWidth - 384) / 2;
            slider      = new SampleSlider(sx, 360, 384, 48);
            slider.Rate = rate;
            oldRate     = rate;

            // for text dialog setting
            byte[] byteArrayD0 = new byte[4];
            for (int i = 0; i < 4; i++)
            {
                byteArrayD0[i] = persistentMemoryData[STATE_ADDR_STRING_NO + i];
            }
            int len      = BitConverter.ToInt32(byteArrayD0, 0);
            int readSize = len * 2;

            byte[] byteArrayD1 = new byte[readSize];
            for (int i = 0; i < readSize; i++)
            {
                byteArrayD1[i] = persistentMemoryData[STATE_ADDR_STRING + i];
            }

            string label = "";

            if (len != 0)
            {
                label = System.Text.Encoding.Unicode.GetString(byteArrayD1);
            }

            sx = (screenWidth - 480) / 2;
            inputTextButton = new SampleButton(sx, 256, 480, 32);
            inputTextButton.SetText(label, SampleButton.TextAlign.Left, SampleButton.VerticalAlign.Middle);
            dialog = null;
        }