コード例 #1
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
            {
                content = ScreenManager.Game.Content;
            }

            //gameFont = content.Load<SpriteFont>("GSMgamefont");

            m_World = new World(new Vector2(0, 0));
            ConvertUnits.SetDisplayUnitToSimUnitRatio(5);

            Player p = Player.Load(content);

            if (p == null)
            {
                Vector2 playerPosition = new Vector2(Game1.GameWidth / 2, Game1.GameHeight / 2);
                m_Player.Init(content, playerPosition);
            }
            else
            {
                m_Player = p;
            }
            //init object manager and set objects for it
            GlobalObjectManager.Init(m_Player, content, m_World);
            TextureBank.SetContentManager(content);
            SoundBank.SetContentManager(content);
            m_Player.LoadContent(m_World);
            UserInterface.LoadContent(content, Game1.GameWidth, Game1.GameHeight);
            GlobalObjectManager.LoadContent();

            m_song = SoundBank.GetSong("PUNCHING-Edit");
            UserInterface.SetTimeToDeath(m_Player.TimeToDeath);

            Zombie.LoadTextures();
            Slime.LoadTextures();
            Anubis.LoadTextures();


            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;

            backgroundTexture = new RenderTarget2D(ScreenManager.GraphicsDevice, viewport.Width, viewport.Height, false,
                                                   SurfaceFormat.Color, DepthFormat.None, ScreenManager.GraphicsDevice.PresentationParameters.MultiSampleCount, RenderTargetUsage.PreserveContents);


            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;

            GraphicsDevice device = ScreenManager.GraphicsDevice;

            device.SetRenderTarget(backgroundTexture);
            spriteBatch.Begin();
            UserInterface.DrawBackground(spriteBatch);
            spriteBatch.End();

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();

            m_World.Step(0f);

            isLoaded = true;
        }