예제 #1
0
        /// <summary>
        /// Asetetaan ohjaimet varsinaista peliä varten
        /// </summary>
        private void AsetaOhjaimet()
        {
            Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Show help");
            Keyboard.Listen(Key.F5, ButtonState.Pressed, Begin, "New game");
            // Keyboard.Listen(Key.Escape, ButtonState.Pressed, KysyLopetus, "Exit game");
            Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Exit game");
            Keyboard.Listen(Key.Up, ButtonState.Down, KaannaMailaa, "Move up", 5.0);
            Keyboard.Listen(Key.Down, ButtonState.Down, KaannaMailaa, "Move down", -5.0);
            Keyboard.Listen(Key.Space, ButtonState.Pressed, PudotaPallo, "Drop ball");

            Mouse.IsCursorVisible = true;
            Mouse.ListenOn(pisteNaytto, MouseButton.Left, ButtonState.Pressed, delegate() { AloitaUusiPeli(); }, null);
            Mouse.Listen(MouseButton.Left, ButtonState.Pressed, delegate() { PudotaPallo(); }, "Drop ball");
            //  Mouse.ListenMovement(0.1, delegate (AnalogState analogState) { Tahtaa(Mouse.PositionOnWorld); }, "Aim");
            Mouse.ListenMovement(0.1, () => { Tahtaa(Mouse.PositionOnWorld); }, "Aim");

            TouchPanel.ListenOn(pisteNaytto, ButtonState.Pressed, delegate(Touch kosketus) { AloitaUusiPeli(); }, null);
            TouchPanel.Listen(ButtonState.Pressed, delegate(Touch kosketus) { PudotaPallo(); }, "Drop ball");
            TouchPanel.Listen(ButtonState.Down, delegate(Touch kosketus) { Tahtaa(kosketus.PositionOnWorld); }, "Aim");
            // PhoneBackButton.Listen(KysyLopetus, "Lopeta peli");
            PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");

#if ANDROID // lisää tähän ehtoa jos muitakin kallistelun tukevia
            Accelerometer.Calibration = AccelerometerCalibration.ZeroAngle;
            Accelerometer.ListenAnalog(AccelerometerSensitivity.Realtime, TahtaaAccel, "Aim");
            Accelerometer.Listen(AccelerometerDirection.Shake, delegate { PudotaPallo(); }, "Drop ball");
#endif
        }