Exemple #1
0
 // create a butterfly
 private void CreateButterfly()
 {
     butterfly = new Butterfly
     {
         LocationX = MyCanvas.Width / 2 - 75,
         LocationY = MyCanvas.Height / 2 - 66
     };
     // add to canvas
     MyCanvas.Children.Add(butterfly);
     // show in right location
     butterfly.SetLocation();
 }
Exemple #2
0
        public MainPage()
        {
            this.InitializeComponent();

            // windows size 800*600
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
            ApplicationView.PreferredLaunchViewSize = new Size(800, 600);

            // get Canvas size 
            CanvasWidth = MyCanvas.Width -150;
            CanvasHeight = MyCanvas.Height -132;

            // add butterfly
            butterfly = new Butterfly
            {
                LocationX = CanvasWidth/2,
                LocationY = CanvasHeight/2
            };
            MyCanvas.Children.Add(butterfly);
            butterfly.UpdatePosition();

            //add flower
            AddFlower();

            //Load Audio
            LoadAudio();

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

            // initialize game loop
            timer = new DispatcherTimer();
            timer.Tick += Timer_Tick;
            timer.Interval = new TimeSpan(0, 0, 0, 0, 1000/120); //try 120fps
            timer.Start();
        }
Exemple #3
0
        public MainPage()
        {
            this.InitializeComponent();

            // windows size 800*600
            ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize;
            ApplicationView.PreferredLaunchViewSize      = new Size(800, 600);

            // get Canvas size
            CanvasWidth  = MyCanvas.Width - 150;
            CanvasHeight = MyCanvas.Height - 132;

            // add butterfly
            butterfly = new Butterfly
            {
                LocationX = CanvasWidth / 2,
                LocationY = CanvasHeight / 2
            };
            MyCanvas.Children.Add(butterfly);
            butterfly.UpdatePosition();

            //add flower
            AddFlower();

            //Load Audio
            LoadAudio();

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

            // initialize game loop
            timer          = new DispatcherTimer();
            timer.Tick    += Timer_Tick;
            timer.Interval = new TimeSpan(0, 0, 0, 0, 1000 / 120); //try 120fps
            timer.Start();
        }