示例#1
0
        public MainPage()
        {
            this.InitializeComponent();

            // Create a butterfly
            butterfly = new Butterfly
            {
                LocationX = MyCanvas.Width / 2,
                LocationY = MyCanvas.Height / 2
            };
            // Add butterfly to Canvas
            MyCanvas.Children.Add(butterfly);

            // Init list of flowers
            flowers = new List <Flower>();

            // Key listeners
            Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;
            Window.Current.CoreWindow.KeyUp   += CoreWindow_KeyUp;

            // Mouse listener
            Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed;

            // Load audio
            LoadAudio();

            // Start game loop
            timer          = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 0, 0, 1000 / 60);
            timer.Tick    += Timer_Tick;
            timer.Start();
        }
示例#2
0
        public MainPage()
        {
            this.InitializeComponent();

            // add butterfly
            butterfly = new Butterfly
            {
                LocationX = MyCanvas.Width / 2,
                LocationY = MyCanvas.Height / 2
            };
            // Add butterfly to Canvas, lisätään perhonen Canvakselle
            MyCanvas.Children.Add(butterfly);

            // Init list of Flowers, alustetaan kukkalista
            flowers = new List <Flower>();

            // Key Listeners,   näppäimien kuuntelua, onko jokin painettuna vai ei?
            Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;  // Onko näppäimi alhaalla
            Window.Current.CoreWindow.KeyUp   += CoreWindow_KeyUp;    //Onko näppäimiä "ylhäällä"

            // Mouse Listeners,  hiiren kuuntelu
            Window.Current.CoreWindow.PointerPressed += CoreWindow_PointerPressed;

            // Load Audio, ladataan ääni
            LoadAudio();

            // Start game loop,     PELI LÄHTEE HETI KÄYNTIIN
            timer          = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 0, 0, 1000 / 60);
            timer.Tick    += Timer_Tick;
            timer.Start();
        }