コード例 #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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

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

            // Load textures

            texSinglePixel = Content.Load <Texture2D>("singlepixel");

            for (int i = 0; i < 2; i++)
            {
                texBgs.Add(Content.Load <Texture2D>("sprBg" + i));
            }

            texBtnPlay      = Content.Load <Texture2D>("sprBtnPlay");
            texBtnPlayDown  = Content.Load <Texture2D>("sprBtnPlayDown");
            texBtnPlayHover = Content.Load <Texture2D>("sprBtnPlayHover");

            texBtnRestart      = Content.Load <Texture2D>("sprBtnRestart");
            texBtnRestartDown  = Content.Load <Texture2D>("sprBtnRestartDown");
            texBtnRestartHover = Content.Load <Texture2D>("sprBtnRestartHover");

            texPlayer      = Content.Load <Texture2D>("sprPlayer");
            texPlayerLaser = Content.Load <Texture2D>("sprLaserPlayer");
            texEnemyLaser  = Content.Load <Texture2D>("sprLaserEnemy0");

            for (int i = 0; i < 3; i++)
            {
                texEnemies.Add(Content.Load <Texture2D>("sprEnemy" + i));
            }

            texExplosion = Content.Load <Texture2D>("sprExplosion");

            // Load sounds
            sndBtnDown = Content.Load <SoundEffect>("sndBtnDown");
            sndBtnOver = Content.Load <SoundEffect>("sndBtnOver");
            for (int i = 0; i < 2; i++)
            {
                sndExplode.Add(Content.Load <SoundEffect>("sndExplode" + i));
            }
            sndLaser = Content.Load <SoundEffect>("sndLaser");


            // Load sprite fonts

            fontArial = Content.Load <SpriteFont>("arialHeading");

            scrollingBackground = new ScrollingBackground(texBgs);


            playButton    = new MenuButton(this, new Vector2(graphics.PreferredBackBufferWidth * 0.5f - (int)(texBtnPlay.Width * 0.5), graphics.PreferredBackBufferHeight * 0.5f), texBtnPlay, texBtnPlayDown, texBtnPlayHover);
            restartButton = new MenuButton(this, new Vector2(graphics.PreferredBackBufferWidth * 0.5f - (int)(texBtnPlay.Width * 0.5), graphics.PreferredBackBufferHeight * 0.5f), texBtnRestart, texBtnRestartDown, texBtnRestartHover);


            changeGameState(GameState.MainMenu);
        }
 public ScrollingBackgroundLayer(ScrollingBackground scrollingBackground, Texture2D texture, int depth, int positionIndex, Vector2 position, Vector2 velocity) : base()
 {
     this.scrollingBackground = scrollingBackground;
     this.texture             = texture;
     this.depth         = depth;
     this.positionIndex = positionIndex;
     this.position      = position;
     initialPosition    = this.position;
     body.velocity      = velocity;
 }