Tetris.Score.Initialize C# (CSharp) Method

Initialize() public method

Allows the game component to perform any initialization it needs to before starting to run. This is where it can query for any required services and load content.
public Initialize ( ) : void
return void
        public override void Initialize()
        {
            value = 0;
            level = 1;
            base.Initialize();
        }

Usage Example

Example #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);

            // Add the SpriteBatch service
            Services.AddService(typeof(SpriteBatch), spriteBatch);

            //Load 2D textures
            tetrisBackground = Content.Load <Texture2D> ("background");
            tetrisTextures   = Content.Load <Texture2D> ("tetris");

            // Load game font
            //gameFont = Content.Load<SpriteFont> ("font");
            gameFont = Content.Load <SpriteFont> ("Arial");

            // Create game field
            board = new Board(this, ref tetrisTextures, blockRectangles);
            board.Initialize();
            Components.Add(board);

            // Save player's score and game level
            score = new Score(this, gameFont);
            score.Initialize();
            Components.Add(score);

            // Load game record
            using (StreamReader streamReader = File.OpenText("record.dat")) {
                string player = null;
                if ((player = streamReader.ReadLine()) != null)
                {
                    score.RecordPlayer = player;
                }
                int record = 0;
                if ((record = Convert.ToInt32(streamReader.ReadLine())) != 0)
                {
                    score.RecordScore = record;
                }
            }
        }
All Usage Examples Of Tetris.Score::Initialize