コード例 #1
0
ファイル: ScrapHeap.cs プロジェクト: nitro404/Scrap_Heap
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // parse and load all sprite sheets
            spriteSheets = SpriteSheetCollection.parseFrom(Content.RootDirectory + "/" + settings.spriteSheetFileName, Content);

            // load game content
            menu.loadContent(Content);

            console.loadContent(Content);

            player.loadContent(Content, spriteSheets.getSpriteSheet("Crosshairs"));

            entitySystem.loadContent(Content);

            // load shaders
            blur = Content.Load <Effect>("Shaders\\Blur");
            post = Content.Load <Effect>("Shaders\\PostFx");

            // load sound information
            audioEngine = new AudioEngine("Content\\Sounds\\ScrapHeap.xgs");
            waveBank    = new WaveBank(audioEngine, "Content\\Sounds\\waveBank.xwb");
            soundBank   = new SoundBank(audioEngine, "Content\\Sounds\\soundBank.xsb");
        }
コード例 #2
0
        // parse a collection of sprite sheets from a specified sprite sheet data file
        public static SpriteSheetCollection parseFrom(String fileName, ContentManager content)
        {
            if (fileName == null || !File.Exists(fileName))
            {
                return(null);
            }

            StreamReader          instream;
            SpriteSheet           spriteSheet;
            SpriteSheetCollection spriteSheets = new SpriteSheetCollection();

            // open the sprite sheet data file and parse until either:
            // an invalid sprite sheet is encountered
            // or the end of the file is encountered
            try {
                instream = File.OpenText(fileName);

                do
                {
                    // parse the sprite sheet and store it
                    spriteSheet = SpriteSheet.parseFrom(instream, content);
                    spriteSheets.addSpriteSheet(spriteSheet);
                } while(spriteSheet != null);

                instream.Close();
            }
            catch (Exception) { return(null); }

            return(spriteSheets);
        }