Пример #1
0
        //Same as createYellowStar
        public void createRedStar()
        {
            for (int i = 0; i < numSpawn; i++)
            {
                int       xPos           = rand.Next((int)bounds.Width - 46);
                int       yPos           = 20;
                animation movementSpeed2 = new animation(xPos, yPos);
                lstMovement2.Add(movementSpeed2);


                imStar2        = new Image();
                imStar2.Source = new BitmapImage(new Uri("ms-appx:///Assets/Star2.png"));
                imStar2.SetValue(Canvas.LeftProperty, xPos);
                imStar2.SetValue(Canvas.TopProperty, yPos);
                canGameStars.Children.Add(imStar2);
                lstStar2.Add(imStar2);
            }
        }
Пример #2
0
        // ** Parts of this method were adapted from the week two turorial from INFT2050 in MobileGame.zip **
        public void createYellowStar() //The method for creating the Yellow stars
        {
            for (int i = 0; i < numSpawn; i++)
            {
                int       xPos     = rand.Next((int)bounds.Width - 46); //Assigns random x coordinate from the width of the screen
                int       yPos     = 20;                                // Sets the starting y coordinate as 20
                animation position = new animation(xPos, yPos);         //Assigns x and y to object of animation class
                lstMovement.Add(position);                              // adds object to list

                //Creates a new star image, sets the renderTransformOrgin so that it can rotate, sets the starting position and finally adds to canvas and list.
                imStar        = new Image();
                imStar.Source = new BitmapImage(new Uri("ms-appx:///Assets/Star.png"));
                imStar.RenderTransformOrigin = new Point(0.5, 0.5);
                imStar.SetValue(Canvas.LeftProperty, xPos);
                imStar.SetValue(Canvas.TopProperty, yPos);
                canGameStars.Children.Add(imStar);
                lstStar.Add(imStar);
            }
        }
        public void createStar()
        {
            //numSpawn = rand.Next(3, 10);

            for (int i = 0; i < numSpawn; i++)
            {
                int       xPos          = rand.Next((int)bounds.Width);
                int       yPos          = 20;
                int       xSpeed        = 2 + rand.Next(2);
                int       ySpeed        = 2 + rand.Next(2);
                animation movementSpeed = new animation(xPos, yPos, xSpeed, ySpeed);
                lstMovement.Add(movementSpeed);


                Image imStar = new Image();
                imStar.Source = new BitmapImage(new Uri("ms-appx:///Assets/Star.png"));
                imStar.SetValue(Canvas.LeftProperty, xPos);
                imStar.SetValue(Canvas.TopProperty, yPos);
                canGameBoard.Children.Add(imStar);
                lstStar.Add(imStar);
            }
        }