Пример #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Создание обьекта SpriteBatch для вывода 2D графики на экран.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            playerPacMan = new Player(Content.Load<Texture2D>("Pacman_HD"), new Rectangle(510, 490, 35, 35));  //500 501
            gameField = new Field(Content.Load<Texture2D>("fieldTile"), new Rectangle(0,0,35,35));
            fieldTileCenterTexture2D = Content.Load<Texture2D>("fieldTileCenter");

            fieldTileLeftTexture2D = Content.Load<Texture2D>("fieldTileLeft");
            fieldTileRightTexture2D = Content.Load<Texture2D>("fieldTileRight");

                ghostsRed = new Ghost(Content.Load<Texture2D>("GhostRed"), new Rectangle(455, 320, 35, 35));
                ghostsYellow = new Ghost(Content.Load<Texture2D>("GhostYellow"), new Rectangle(490, 320, 35, 35));
                ghostsBlue = new Ghost(Content.Load<Texture2D>("GhostBlue"), new Rectangle(525, 320, 35, 35));
                ghostsPink = new Ghost(Content.Load<Texture2D>("GhostPink"), new Rectangle(560, 320, 35, 35));

                ghostsRed.SetSpriteBanch(spriteBatch);
                ghostsYellow.SetSpriteBanch(spriteBatch);
                ghostsBlue.SetSpriteBanch(spriteBatch);
                ghostsPink.SetSpriteBanch(spriteBatch);

            playerPacMan.SetSpriteBanch(spriteBatch);

            playerPacMan.SetLeftImage(Content.Load<Texture2D>("Pacman_HD_left"));
            playerPacMan.SetRightImage(Content.Load<Texture2D>("Pacman_HD_right"));
            playerPacMan.SetDownImage(Content.Load<Texture2D>("Pacman_HD_down"));
            playerPacMan.SetUpImage(Content.Load<Texture2D>("Pacman_HD_up"));

            //CreateField();

            playerPacMan.SetCurrentField(gameField);
            ghostsRed.SetCurrentField(gameField);
            ghostsYellow.SetCurrentField(gameField);
            ghostsBlue.SetCurrentField(gameField);
            ghostsPink.SetCurrentField(gameField);

            // TODO: use this.Content to load your game content here
        }